home *** CD-ROM | disk | FTP | other *** search
/ Creative Computers / Creative Computers CD-ROM, Volume 1 (Legendary Design Technologies, Inc.)(1994).iso / shareware / games / uchess / src / main.c < prev    next >
C/C++ Source or Header  |  1994-11-17  |  160KB  |  5,934 lines

  1. /*#define EIGHT_BIT_SCREEN 1 */
  2.  
  3. /* main.c - C source for GNU CHESS
  4.  *
  5.  * Copyright (c) 1988,1989,1990 John Stanback
  6.  * Copyright (c) 1992 Free Software Foundation
  7.  *
  8.  * This file is part of GNU CHESS.
  9.  *
  10.  * GNU Chess is free software; you can redistribute it and/or modify
  11.  * it under the terms of the GNU General Public License as published by
  12.  * the Free Software Foundation; either version 2, or (at your option)
  13.  * any later version.
  14.  *
  15.  * GNU Chess is distributed in the hope that it will be useful,
  16.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  18.  * GNU General Public License for more details.
  19.  *
  20.  * You should have received a copy of the GNU General Public License
  21.  * along with GNU Chess; see the file COPYING.  If not, write to
  22.  * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  23.  */
  24.  
  25. int __aligned CheckIllegal = 0;
  26. extern int IllegalMove;
  27. #include "version.h"
  28. #include "gnuchess.h"
  29. #include <signal.h>
  30. #include <ctype.h>
  31.  
  32. #ifdef AMIGA
  33. #define EXCLUDE_PATT 0xffffff00L
  34. #define __USE_SYSBASE
  35. #include <exec/types.h>
  36. #include <exec/exec.h>
  37. #include <proto/exec.h>
  38. #include <proto/dos.h>
  39. #include <proto/graphics.h>
  40. #include <graphics/gfxbase.h>
  41. #include <proto/intuition.h>
  42. #include <utility/tagitem.h>
  43. #include <graphics/modeid.h>
  44. #include <lhlib.h>
  45. #include <libraries/asl.h>
  46. #include <proto/icon.h>
  47. #include <proto/asl.h>
  48. #include <workbench/startup.h>
  49. #include <workbench/workbench.h>
  50.  
  51.  
  52. #define mySetABPenDrMd(a,b,c,d) if (gfxversion > 38) {SetABPenDrMd(a,b,c,d);} else {SetAPen(a,b);SetDrMd(a,d);}
  53.  
  54. extern int __aligned bookflag;
  55. struct __iobuf __iob[1];
  56. #define LN2 693147 /* .693147 */
  57. #define LOGE_34 3526361 /* log2(34) = ln(34)/ln(2) = 5.087463 */
  58. #define LOGE_16 2772589 /* ln(16) = */
  59.  
  60. void SetTimeControl2 (int);
  61. void calc_pgm_rating(void);
  62. void DoEasy(void);
  63. void DoIntermediate(void);
  64. void DoAdvanced(void);
  65. int GetScreenMode(void);
  66.  
  67.  
  68. /* this table index ln(2)*1e6 - ln(1202)*1e6 by 6's */
  69. /* so take (#secs - 2)/6 for index into this table */
  70.  
  71. long __aligned OrigResponse;
  72. int __aligned __far log_e[]={
  73. 693147, 2079442, 2639057, 2995732, 3258097, 3465736, 3637586, 3784190, 
  74. 3912023, 4025352, 4127134, 4219508, 4304065, 4382027, 4454347, 4521789, 
  75. 4584967, 4644391, 4700480, 4753590, 4804021, 4852030, 4897840, 4941642, 
  76. 4983607, 5023881, 5062595, 5099866, 5135798, 5170484, 5204007, 5236442, 
  77. 5267858, 5298317, 5327876, 5356586, 5384495, 5411646, 5438079, 5463832, 
  78. 5488938, 5513429, 5537334, 5560682, 5583496, 5605802, 5627621, 5648974, 
  79. 5669881, 5690359, 5710427, 5730100, 5749393, 5768321, 5786897, 5805135, 
  80. 5823046, 5840642, 5857933, 5874931, 5891644, 5908083, 5924256, 5940171, 
  81. 5955837, 5971262, 5986452, 6001415, 6016157, 6030685, 6045005, 6059123, 
  82. 6073045, 6086775, 6100319, 6113682, 6126869, 6139885, 6152733, 6165418, 
  83. 6177944, 6190315, 6202536, 6214608, 6226537, 6238325, 6249975, 6261492, 
  84. 6272877, 6284134, 6295266, 6306275, 6317165, 6327937, 6338594, 6349139, 
  85. 6359574, 6369901, 6380123, 6390241, 6400257, 6410175, 6419995, 6429719, 
  86. 6439350, 6448889, 6458338, 6467699, 6476972, 6486161, 6495266, 6504288, 
  87. 6513230, 6522093, 6530878, 6539586, 6548219, 6556778, 6565265, 6573680, 
  88. 6582025, 6590301, 6598509, 6606650, 6614726, 6622736, 6630683, 6638568, 
  89. 6646391, 6654153, 6661855, 6669498, 6677083, 6684612, 6692084, 6699500, 
  90. 6706862, 6714171, 6721426, 6728629, 6735780, 6742881, 6749931, 6756932, 
  91. 6763885, 6770789, 6777647, 6784457, 6791221, 6797940, 6804615, 6811244, 
  92. 6817831, 6824374, 6830874, 6837333, 6843750, 6850126, 6856462, 6862758, 
  93. 6869014, 6875232, 6881411, 6887553, 6893656, 6899723, 6905753, 6911747, 
  94. 6917706, 6923629, 6929517, 6935370, 6941190, 6946976, 6952729, 6958448, 
  95. 6964136, 6969791, 6975414, 6981006, 6986566, 6992096, 6997596, 7003065, 
  96. 7008505, 7013915, 7019297, 7024649, 7029973, 7035269, 7040536, 7045777, 
  97. 7050989, 7056175, 7061334, 7066467, 7071573, 7076654, 7081709, 7086738, 
  98. 7091742};
  99.  
  100.  
  101. /* Structure for transparent images */
  102.  
  103. #define PTRHEIGHT 55
  104.  
  105. #define BLANKDATA 0xffff
  106.  
  107. extern int SecsPerMove;
  108. int __aligned lastpiece=BLANKDATA;
  109.  
  110. void Undo(void);
  111.  
  112. char __aligned __far vstring[64]={AVSTR};
  113.  
  114. long __far __aligned piecechar[12]={'p','n','b','r','q','k',
  115.                           'P','N','B','R','Q','K'};
  116. char __far __aligned oldboard[8][8];
  117.  
  118. int __far __aligned BACKPEN=1;
  119.  
  120. int __aligned BLACK=1;
  121.  
  122. //int __aligned Picasso=0L;
  123. ULONG __far __aligned bpen;
  124. int __aligned PlayMode = 2;
  125. int __aligned global_tmp_score=0;
  126. int __aligned previous_score=0;
  127. extern short int ISZERO;
  128. extern int thinkahead;
  129. unsigned long int __aligned next = 1;
  130. int __aligned doswap=0;
  131. int __aligned doundo=0;
  132. int __aligned doauto=0;
  133. int __aligned gfxversion=0L;
  134. int __aligned v15Khz=0L;
  135. int __aligned teston=0;
  136. int __aligned cmptr_sec,cmptr_min,hum_sec,hum_min;
  137. struct TagItem __aligned __far myTagList[8] = {
  138. {SA_DisplayID,VGAPRODUCT_KEY},
  139. {SA_Overscan,OSCAN_STANDARD},
  140. {0,0},
  141. {0,0},
  142. {0,0}
  143. };
  144.  
  145. int __aligned MoveNowOK=0;
  146.  
  147. #define WINDOWSIGNAL (1L<<(wG->UserPort->mp_SigBit))
  148. ULONG __aligned globalsignalset=0L;
  149.  
  150. ULONG __aligned RTG_ModeID=0x0L;
  151. int __aligned Super72=0;
  152. int __aligned RTG=0;
  153. int __aligned SYSTEM_BOBS=1;
  154. int __aligned procpri=3;
  155. struct Process __aligned *myproc;
  156.  
  157. int __aligned __far ResignOffered=0;
  158. //ULONG __far __aligned tmppal[4];
  159.  
  160. inline void TimeCalc (void);
  161.  
  162.  
  163. int __far __aligned FasterDisplay=0;
  164. int __aligned trying_again=0;
  165. int __aligned SupervisorMode=0;
  166. int __aligned MenuStripSet = 0;
  167. int __aligned GlobalTgtDepth=3;
  168.  
  169. UWORD chip myPointer[]={
  170. 0,0,
  171. 31744,0,
  172. 4096,0,
  173. 4096,0,
  174. 4096,0,
  175. 4096,0,
  176. 5120,0,
  177. 5120,0,
  178. 1024,0,
  179. 1920,0,
  180. 1152,0,
  181. 1152,0,
  182. 1152,0,
  183. 256,0,
  184. 0,0,
  185. 768,0,
  186. 256,0,
  187. 256,0,
  188. 256,0,
  189. 896,0,
  190. 0,0,
  191. 896,0,
  192. 576,0,
  193. 576,0,
  194. 576,0,
  195. 576,0,
  196. 0,0,
  197. 512,0,
  198. 512,0,
  199. 576,0,
  200. 640,0,
  201. 896,0,
  202. 640,0,
  203. 576,0,
  204. 0,0,
  205. 256,0,
  206. 0,0,
  207. 768,0,
  208. 256,0,
  209. 256,0,
  210. 256,0,
  211. 896,0,
  212. 0,0,
  213. 0,0,
  214. 896,0,
  215. 576,0,
  216. 576,0,
  217. 576,0,
  218. 576,0,
  219. 0,0,
  220. 960,0,
  221. 576,0,
  222. 576,0,
  223. 960,0,
  224. 64,0,
  225. 960,0,
  226. 0,0
  227. };
  228.  
  229.  
  230. struct TransImage
  231. {
  232.     struct Image *ti_IM;    /* The plain image */
  233.     struct BitMap *ti_sBM;    /* Shadow bitmap */
  234.     struct RastPort *ti_sRP;    /* Shadow rastport */
  235.     struct BitMap ti_BM;    /* Image bitmap */
  236.     struct RastPort ti_RP;    /* Image rastport */
  237. };
  238.  
  239. struct Image __aligned BobImage;
  240.  
  241. struct TransImage __aligned *BobTransImage;
  242.  
  243. struct TransImage *AllocTransImage (struct Image * im);
  244. VOID FreeTransImage (struct TransImage * ti);
  245. VOID ClipBlitTrans (struct RastPort *, WORD, WORD, struct RastPort *, WORD, WORD, WORD, WORD, struct RastPort *);
  246. struct BitMap *AllocShadowBM (UWORD, UWORD, UWORD);
  247. VOID FreeShadowBM (struct BitMap *);
  248. struct RastPort *AllocShadowRP (struct BitMap *);
  249. VOID FreeShadowRP (struct RastPort *);
  250. long __aligned OrigCol,OrigRow,DestCol,DestRow;
  251.  
  252.  
  253. #define TDEPTH 4
  254. #define THEIGHT 400 /* tmp ht */
  255. #define TBLOCKPEN 4 /* was 9 */
  256. #define MENUPEN 11
  257.  
  258. #ifdef EIGHT_BIT_SCREEN
  259. int __aligned DEPTH=8;
  260. #ifdef MANYP
  261. int __aligned HEIGHT=480;
  262. int __aligned USERBOX=168;
  263. int __aligned COMPUTERBOX=60;
  264. int __aligned BACKGNDTEXTCOLOR=0xe0; /* for 256 use 0xe0 */
  265. int __aligned BOBHEIGHT=55; /* 55 for 480 screens */
  266. int __aligned ROW8=24; /* 24 for 480 screens */
  267. int __aligned MBLOCKPEN=251;
  268. #endif
  269. #else
  270. int __aligned DEPTH=4;
  271. #endif
  272.  
  273. int __aligned TCadd = 0;
  274. int __aligned thinking2=0; /* look for move now menu selection in elasped time when set */
  275. int __aligned TIMEYCOORD1=100;
  276. int __aligned TIMEYCOORD2=192;
  277. int __aligned SYSBOXLEN=86;
  278. int __aligned HEIGHT=400;
  279. int __aligned USERBOX=140;
  280. int __aligned SYSTEMBOX=233;
  281. int __aligned COMPUTERBOX=50;
  282. int __aligned BACKGNDTEXTCOLOR=15; /* for 256 use 0xe0 */
  283. int __aligned BOBHEIGHT=46; /* 55 for 480 screens */
  284. int __aligned ROW8=20; /* 24 for 480 screens */
  285. int __aligned MBLOCKPEN=9;
  286.  
  287. #define MENUBARHT 11
  288. #define WIDTH 640
  289. #define VIEWMODES (HIRES|LACE)
  290.  
  291. int __aligned BOBDEPTH=TDEPTH;
  292.  
  293. #define BOARDWIDTH 640
  294. #define BOARDWIDINW 40
  295. #define BOARDSIZE (480*DEPTH*BOARDWIDINW*sizeof(WORD))
  296. #define BOARDBLOCKSIZE ((BOARDSIZE+(BOARDWIDINW*sizeof(WORD))*(480+2))+(BOARDWIDINW*sizeof(WORD)))
  297.  
  298. #define BOBWIDTH 64 /* only 59 pixels are really used, rest are tranparent */
  299. #define BOBWIDINW 4
  300. #define BOBSIZE (BOBHEIGHT*BOBDEPTH*BOBWIDINW*sizeof(WORD))
  301. #define BOBBLOCKSIZE ((BOBSIZE)+(BOBWIDINW*sizeof(WORD)*(BOBHEIGHT+2))+(BOBWIDINW*sizeof(WORD)))
  302.  
  303. #define BOBLW ((BOBBLOCKSIZE)/4)
  304. #define BOBMEMASK 0
  305. #define BOBHITMASK 0
  306. int __aligned BOBPLANEPICK=0xf; /* if 16 colors should be 0xf if 256 should be 0xff */
  307. #define BOBPLANEONOFF 0x0
  308.  
  309. #define SQUAREWIDTH 59
  310. #define ROUNDEDSQUAREWIDTH 64
  311. #define SQUAREHEIGHT BOBHEIGHT
  312. #define COLA (16)
  313. #define COLB (16+SQUAREWIDTH)
  314. #define COLC (16+SQUAREWIDTH*2)
  315. #define COLD (16+SQUAREWIDTH*3)
  316. #define COLE (16+SQUAREWIDTH*4)
  317. #define COLF (16+SQUAREWIDTH*5)
  318. #define COLG (16+SQUAREWIDTH*6)
  319. #define COLH (16+SQUAREWIDTH*7)
  320. #define ROW7 (ROW8+SQUAREHEIGHT)
  321. #define ROW6 (ROW8+SQUAREHEIGHT*2)
  322. #define ROW5 (ROW8+SQUAREHEIGHT*3)
  323. #define ROW4 (ROW8+SQUAREHEIGHT*4)
  324. #define ROW3 (ROW8+SQUAREHEIGHT*5)
  325. #define ROW2 (ROW8+SQUAREHEIGHT*6)
  326. #define ROW1 (ROW8+SQUAREHEIGHT*7)
  327.  
  328.  
  329. UWORD __aligned *BlankImageData;
  330.  
  331. UWORD __far __aligned *WhiteImageData[6];
  332. UWORD __far __aligned *BlackImageData[6];
  333.  
  334. void LoadBobImage(long);
  335.  
  336. long __far __aligned ColArray[8]={COLA,COLB,COLC,COLD,COLE,COLF,COLG,COLH};
  337. long __far __aligned RowArray[8];
  338.  
  339. struct VSprite __aligned *SpriteHead;
  340. struct VSprite __aligned *SpriteTail;
  341.  
  342. struct GelsInfo __aligned *myGelsInfo;
  343. struct VSprite __aligned *BobVSprite;
  344. struct Bob __aligned *TheBob;
  345.  
  346. struct BitMap __aligned *WhiteBitMap,*BlackBitMap;
  347. struct BitMap *textBitMap=(struct BitMap *)0L;
  348.  
  349. struct TextFont __aligned *myTextFont;
  350.  
  351. extern struct GfxBase __aligned *Gfxbase;
  352. long __aligned __stack=50000L;
  353. ULONG tt;
  354. struct RastPort __aligned *rpG;
  355. struct ViewPort __aligned *vP;
  356. struct Screen __aligned *sC=0L;
  357. struct Window __aligned *wG=0L;
  358. struct Window __aligned *wGEdit;
  359. unsigned char __far __aligned cookedchar[128]={'~',
  360.                   '1',
  361.                   '2',
  362.                   '3',
  363.                   '4',
  364.                   '5',
  365.                   '6',
  366.                   '7',
  367.                   '8',
  368.                   '9',
  369.                   '0', /* 10 */
  370.                   '-',
  371.                   '=',
  372.                   ' ',
  373.                   ' ',
  374.                   '0',
  375.                   'Q', /* 16 */
  376.                   'W',
  377.                   'E',
  378.                   'R',
  379.                   'T', /* 20 */
  380.                   'Y',
  381.                   'U',
  382.                   'I',
  383.                   'O',
  384.                   'P', /* 25 */
  385.                   '[',
  386.                   ']',
  387.                   ' ',
  388.                   '1',
  389.                   '2',
  390.                   '3',
  391.                   'A',
  392.                   'S',
  393.                   'D',
  394.                   'F',
  395.                   'G',
  396.                   'H',
  397.                   'J',
  398.                   'K',
  399.                   'L', /* 40 */
  400.                   ':',
  401.                   '"',
  402.                   13,
  403.                   ' ',
  404.                   '4',
  405.                   '5',
  406.                   '6',
  407.                   ' ',
  408.                   'Z',
  409.                   'X', /* 50 */
  410.                   'C',
  411.                   'V',
  412.                   'B',
  413.                   'N',
  414.                   'M', /* 55 */
  415.                   ',',
  416.                   '.',
  417.                   '/',
  418.                   ' ',
  419.                   '.',
  420.                   '7',
  421.                   '8',
  422.                   '9',
  423.                   ' ',
  424.                   7,
  425.                   8,
  426.                   13,
  427.                   13,
  428.                   27,
  429.                   7
  430. };
  431.  
  432.  
  433.  
  434.  
  435. char __aligned *Orig_PlanePtr;
  436. struct BitMap __aligned *myBitMap;
  437. struct BitMap __aligned *OrigmyBitMap=0L;
  438.  
  439. #include "Chess256Palette.c"
  440.  
  441. UWORD __far __aligned myPalette[16]=
  442. {
  443. 0xfbc, 0x632, 0x455, 0x842, 0x549, 0xa53, 0x787, 0xa56, 
  444. 0x967, 0xa85, 0x3ab, 0xaaa, 0xe88, 0xdb8, 0x333, 0xeee
  445. };
  446.  
  447. #ifdef OLDPAL
  448. {
  449. 0x0, 0x222, 0x410, 0x333, 
  450. 0x621, 0x624, 0x952, 0x665, 
  451. 0x974, 0x887, 0xb85, 0xaa9, 
  452. 0xbb7, 0xcc8, 0xcc9, 0xddc};
  453. #endif 
  454.  
  455. struct TextAttr __far __aligned TOPAZ80 = {
  456.     (STRPTR)"topaz.font",
  457.     TOPAZ_EIGHTY,0,0
  458. };
  459.  
  460. SHORT __far __aligned BorderVectors6[] = {
  461.     0,0,
  462.     44,0,
  463.     44,19,
  464.     0,19,
  465.     0,0
  466. };
  467. struct Border __far __aligned Border6 = {
  468.     -1,-1,    /* XY origin relative to container TopLeft */
  469.     TBLOCKPEN,0,JAM1,    /* front pen, back pen and drawmode */
  470.     5,    /* number of XY vectors */
  471.     BorderVectors6,    /* pointer to XY vectors */
  472.     NULL    /* next border in list */
  473. };
  474.  
  475. struct IntuiText __far __aligned IText93 = {
  476.     TBLOCKPEN,0,JAM2,    /* front and back text pens, drawmode and fill byte */
  477.     12,6,    /* XY origin relative to container TopLeft */
  478.     NULL,    /* font pointer or NULL for default */
  479.     "OK",    /* pointer to text */
  480.     NULL    /* next IntuiText structure */
  481. };
  482.  
  483. struct Gadget __far __aligned Gadget9 = {
  484.     NULL,    /* next gadget */
  485.     109,64,    /* origin XY of hit box relative to window TopLeft */
  486.     43,18,    /* hit box width and height */
  487.     NULL,    /* gadget flags */
  488.     RELVERIFY,    /* activation flags */
  489.     BOOLGADGET,    /* gadget type flags */
  490.     (APTR)&Border6,    /* gadget border or image to be rendered */
  491.     NULL,    /* alternate imagery for selection */
  492.     &IText93,    /* first IntuiText structure */
  493.     NULL,    /* gadget mutual-exclude long word */
  494.     NULL,    /* SpecialInfo structure */
  495.     NULL,    /* user-definable data */
  496.     NULL    /* pointer to user-definable data */
  497. };
  498.  
  499. UBYTE __aligned Gadget8SIBuff[8];
  500. struct StringInfo __aligned Gadget8SInfo = {
  501.     Gadget8SIBuff,    /* buffer where text will be edited */
  502.     NULL,    /* optional undo buffer */
  503.     0,    /* character position in buffer */
  504.     5,    /* maximum number of characters to allow */
  505.     0,    /* first displayed character buffer position */
  506.     0,0,0,0,0,    /* Intuition initialized and maintained variables */
  507.     0,    /* Rastport of gadget */
  508.     0,    /* initial value for integer gadgets */
  509.     NULL    /* alternate keymap (fill in if you set the flag) */
  510. };
  511.  
  512. SHORT __far __aligned BorderVectors7[] = {
  513.     0,0,
  514.     45,0 /* was 45 */,
  515.     45,14, /* was 17 */
  516.     0,14,
  517.     0,0
  518. };
  519. struct Border __far __aligned Border7 = {
  520.     -1,-1,    /* XY origin relative to container TopLeft */
  521.     TBLOCKPEN,0,JAM1,    /* front pen, back pen and drawmode */
  522.     5,    /* number of XY vectors */
  523.     BorderVectors7,    /* pointer to XY vectors */
  524.     NULL    /* next border in list */
  525. };
  526.  
  527. struct Gadget __far __aligned Gadget8 = {
  528.     &Gadget9,    /* next gadget */
  529.     136,32,    /* origin XY of hit box relative to window TopLeft */
  530.     44,16,    /* hit box width and height */
  531.     NULL,    /* gadget flags */
  532.     RELVERIFY,    /* activation flags */
  533.     STRGADGET,    /* gadget type flags */
  534.     (APTR)&Border7,    /* gadget border or image to be rendered */
  535.     NULL,    /* alternate imagery for selection */
  536.     NULL,    /* first IntuiText structure */
  537.     NULL,    /* gadget mutual-exclude long word */
  538.     (APTR)&Gadget8SInfo,    /* SpecialInfo structure */
  539.     NULL,    /* user-definable data */
  540.     NULL    /* pointer to user-definable data */
  541. };
  542.  
  543.  
  544. UBYTE __aligned Gadget6SIBuff[8];
  545. struct StringInfo __aligned Gadget6SInfo = {
  546.     Gadget6SIBuff,    /* buffer where text will be edited */
  547.     NULL,    /* optional undo buffer */
  548.     0,    /* character position in buffer */
  549.     4,    /* maximum number of characters to allow */
  550.     0,    /* first displayed character buffer position */
  551.     0,0,0,0,0,    /* Intuition initialized and maintained variables */
  552.     0,    /* Rastport of gadget */
  553.     0,    /* initial value for integer gadgets */
  554.     NULL    /* alternate keymap (fill in if you set the flag) */
  555. };
  556.  
  557. struct Border __far __aligned Border9 = {
  558.     -1,-1,    /* XY origin relative to container TopLeft */
  559.     TBLOCKPEN,0,JAM1,    /* front pen, back pen and drawmode */
  560.     5,    /* number of XY vectors */
  561.     BorderVectors7,    /* pointer to XY vectors */
  562.     NULL    /* next border in list */
  563. };
  564.  
  565. struct Gadget __far __aligned Gadget6 = {
  566.     &Gadget8,    /* next gadget */
  567.     14,32,    /* origin XY of hit box relative to window TopLeft */
  568.     44,16,    /* hit box width and height */
  569.     NULL,    /* gadget flags */
  570.     RELVERIFY,    /* activation flags */
  571.     STRGADGET,    /* gadget type flags */
  572.     (APTR)&Border9,    /* gadget border or image to be rendered */
  573.     NULL,    /* alternate imagery for selection */
  574.     NULL,    /* first IntuiText structure */
  575.     NULL,    /* gadget mutual-exclude long word */
  576.     (APTR)&Gadget6SInfo,    /* SpecialInfo structure */
  577.     NULL,    /* user-definable data */
  578.     NULL    /* pointer to user-definable data */
  579. };
  580.  
  581. struct Gadget __far __aligned Gadget6b = {
  582.     &Gadget9,    /* next gadget */
  583.     14,32,    /* origin XY of hit box relative to window TopLeft */
  584.     44,16,    /* hit box width and height */
  585.     NULL,    /* gadget flags */
  586.     RELVERIFY,    /* activation flags */
  587.     STRGADGET,    /* gadget type flags */
  588.     (APTR)&Border9,    /* gadget border or image to be rendered */
  589.     NULL,    /* alternate imagery for selection */
  590.     NULL,    /* first IntuiText structure */
  591.     NULL,    /* gadget mutual-exclude long word */
  592.     (APTR)&Gadget6SInfo,    /* SpecialInfo structure */
  593.     NULL,    /* user-definable data */
  594.     NULL    /* pointer to user-definable data */
  595. };
  596.  
  597.  
  598. /**/
  599.  
  600.  
  601. struct IntuiText __aligned IText47 = {
  602.     TBLOCKPEN,0,JAM2,    /* front and back text pens, drawmode and fill byte */
  603.     195,36,    /* XY origin relative to container TopLeft */
  604.     NULL,    /* font pointer or NULL for default */
  605.     "Minutes.",    /* pointer to text */
  606.     NULL    /* next IntuiText structure */
  607. };
  608.  
  609. struct IntuiText __far __aligned IText46 = {
  610.     TBLOCKPEN,0,JAM2,    /* front and back text pens, drawmode and fill byte */
  611.     64,35,    /* XY origin relative to container TopLeft */
  612.     NULL,    /* font pointer or NULL for default */
  613.     "Moves in",    /* pointer to text */
  614.     &IText47    /* next IntuiText structure */
  615. };
  616.  
  617. #define IntuiTextList5 IText46
  618.  
  619. struct NewWindow __far __aligned NewWindowStructure5 = {
  620.     161,23,    /* window XY origin relative to TopLeft of screen */
  621.     270,90,    /* window width and height */
  622.     0,TBLOCKPEN,    /* detail and block pens */
  623.     GADGETUP,    /* IDCMP flags */
  624.     SIMPLE_REFRESH+ACTIVATE+NOCAREREFRESH,    /* other window flags */
  625.     &Gadget6,    /* first gadget in gadget list */
  626.     NULL,    /* custom CHECKMARK imagery */
  627.     "Computer Time Ctrl",    /* window title */
  628.     NULL,    /* custom screen pointer */
  629.     NULL,    /* custom bitmap */
  630.     5,5,    /* minimum width and height */
  631.     0xffff,0xffff,    /* maximum width and height */
  632.     CUSTOMSCREEN    /* destination screen type */
  633. };
  634.  
  635.  
  636. struct ExtNewScreen __far __aligned NewScreenStructure = {
  637.     0,0,    /* screen XY origin relative to View */
  638.     WIDTH,THEIGHT,    /* screen width and height */
  639.     4,    /* screen depth (number of bitplanes) */
  640.     0,TBLOCKPEN,    /* detail and block pens */
  641.     VIEWMODES,    /* display modes for this screen */
  642.     CUSTOMBITMAP|CUSTOMSCREEN,    /* screen type */
  643.     &TOPAZ80,    /* pointer to default screen font */
  644.     VERSTRING,    /* screen title */
  645.     NULL,    /* first in list of custom screen gadgets */
  646.     NULL    /* pointer to custom BitMap structure */
  647. };
  648.  
  649. struct ExtNewScreen __far __aligned NewScreenStructure2 = {
  650.     0,0,    /* screen XY origin relative to View */
  651.     WIDTH,480,    /* screen width and height */
  652.     8,    /* screen depth (number of bitplanes) */
  653.     0,251,    /* detail and block pens */
  654.     VIEWMODES,    /* display modes for this screen */
  655.     CUSTOMSCREEN|SCREENBEHIND,    /* screen type */
  656.     &TOPAZ80,    /* pointer to default screen font */
  657.     " ",    /* screen title */
  658.     NULL,    /* first in list of custom screen gadgets */
  659.     NULL    /* pointer to custom BitMap structure */
  660. };
  661.  
  662.  
  663. struct IntuiText __far __aligned IText37 = {
  664.     MENUPEN,1,JAM1,//TBLOCKPEN,1,COMPLEMENT,    /* front and back text pens, drawmode and fill byte */
  665.     0,0,    /* XY origin relative to container TopLeft */
  666.     &TOPAZ80,    /* font pointer or NULL for default */
  667.     "New Game",    /* pointer to text */
  668.     NULL    /* next IntuiText structure */
  669. };
  670.  
  671. struct IntuiText __far __aligned IText1r = {
  672.     MENUPEN,1,JAM1,//TBLOCKPEN,1,COMPLEMENT,    /* front and back text pens, drawmode and fill byte */
  673.     0,0,    /* XY origin relative to container TopLeft */
  674.     &TOPAZ80,    /* font pointer or NULL for default */
  675.     "Set Depth",    /* pointer to text */
  676.     NULL    /* next IntuiText structure */
  677. };
  678.  
  679. struct MenuItem __aligned MenuItem3r = {
  680.     NULL,    /* next MenuItem structure */
  681.     0,32,    /* XY of Item hitbox relative to TopLeft of parent hitbox */
  682.     72,8,    /* hit box width and height */
  683.     ITEMTEXT+ITEMENABLED+HIGHCOMP,    /* Item flags */
  684.     0,    /* each bit mutually-excludes a same-level Item */
  685.     (APTR)&IText1r,    /* Item render  (IntuiText or Image or NULL) */
  686.     NULL,    /* Select render */
  687.     NULL,    /* alternate command-key */
  688.     NULL,    /* SubItem list */
  689.     MENUNULL    /* filled in by Intuition for drag selections */
  690. };
  691.  
  692. struct IntuiText __far __aligned IText1 = {
  693.     MENUPEN,1,JAM1,//TBLOCKPEN,1,COMPLEMENT,    /* front and back text pens, drawmode and fill byte */
  694.     0,0,    /* XY origin relative to container TopLeft */
  695.     &TOPAZ80,    /* font pointer or NULL for default */
  696.     "Set Time",    /* pointer to text */
  697.     NULL    /* next IntuiText structure */
  698. };
  699.  
  700. struct MenuItem __aligned MenuItem3 = {
  701.     &MenuItem3r,    /* next MenuItem structure */
  702.     0,24,    /* XY of Item hitbox relative to TopLeft of parent hitbox */
  703.     72,8,    /* hit box width and height */
  704.     ITEMTEXT+ITEMENABLED+HIGHCOMP,    /* Item flags */
  705.     0,    /* each bit mutually-excludes a same-level Item */
  706.     (APTR)&IText1,    /* Item render  (IntuiText or Image or NULL) */
  707.     NULL,    /* Select render */
  708.     NULL,    /* alternate command-key */
  709.     NULL,    /* SubItem list */
  710.     MENUNULL    /* filled in by Intuition for drag selections */
  711. };
  712.  
  713. struct IntuiText __far __aligned IText2x = {
  714.     MENUPEN,1,JAM1,//TBLOCKPEN,1,COMPLEMENT,    /* front and back text pens, drawmode and fill byte */
  715.     0,0,    /* XY origin relative to container TopLeft */
  716.     &TOPAZ80,    /* font pointer or NULL for default */
  717.     "Rate Pgm",    /* pointer to text */
  718.     NULL    /* next IntuiText structure */
  719. };
  720.  
  721. struct MenuItem __aligned MenuItem3x = {
  722.     &MenuItem3,    /* next MenuItem structure */
  723.     0,16,    /* XY of Item hitbox relative to TopLeft of parent hitbox */
  724.     72,8,    /* hit box width and height */
  725.     ITEMTEXT+ITEMENABLED+HIGHCOMP,    /* Item flags */
  726.     0,    /* each bit mutually-excludes a same-level Item */
  727.     (APTR)&IText2x,    /* Item render  (IntuiText or Image or NULL) */
  728.     NULL,    /* Select render */
  729.     NULL,    /* alternate command-key */
  730.     NULL,    /* SubItem list */
  731.     MENUNULL    /* filled in by Intuition for drag selections */
  732. };
  733.  
  734. struct IntuiText __far __aligned IText2 = {
  735.     MENUPEN,1,JAM1,//TBLOCKPEN,1,COMPLEMENT,    /* front and back text pens, drawmode and fill byte */
  736.     0,0,    /* XY origin relative to container TopLeft */
  737.     &TOPAZ80,    /* font pointer or NULL for default */
  738.     "Test",    /* pointer to text */
  739.     NULL    /* next IntuiText structure */
  740. };
  741.  
  742. struct MenuItem __aligned MenuItem2 = {
  743.     &MenuItem3x,    /* next MenuItem structure */
  744.     0,8,    /* XY of Item hitbox relative to TopLeft of parent hitbox */
  745.     72,8,    /* hit box width and height */
  746.     ITEMTEXT+ITEMENABLED+HIGHCOMP,    /* Item flags */
  747.     0,    /* each bit mutually-excludes a same-level Item */
  748.     (APTR)&IText2,    /* Item render  (IntuiText or Image or NULL) */
  749.     NULL,    /* Select render */
  750.     NULL,    /* alternate command-key */
  751.     NULL,    /* SubItem list */
  752.     MENUNULL    /* filled in by Intuition for drag selections */
  753. };
  754.  
  755. struct IntuiText __far __aligned IText3 = {
  756.     MENUPEN,1,JAM1,//TBLOCKPEN,1,COMPLEMENT,    /* front and back text pens, drawmode and fill byte */
  757.     0,0,    /* XY origin relative to container TopLeft */
  758.     &TOPAZ80,    /* font pointer or NULL for default */
  759.     "Hint",    /* pointer to text */
  760.     NULL    /* next IntuiText structure */
  761. };
  762.  
  763. struct MenuItem __aligned MenuItem1 = {
  764.     &MenuItem2,    /* next MenuItem structure */
  765.     0,0,    /* XY of Item hitbox relative to TopLeft of parent hitbox */
  766.     72,8,    /* hit box width and height */
  767.     ITEMTEXT+COMMSEQ+ITEMENABLED+HIGHCOMP,    /* Item flags */
  768.     0,    /* each bit mutually-excludes a same-level Item */
  769.     (APTR)&IText3,    /* Item render  (IntuiText or Image or NULL) */
  770.     NULL,    /* Select render */
  771.     'H',    /* alternate command-key */
  772.     NULL,    /* SubItem list */
  773.     MENUNULL    /* filled in by Intuition for drag selections */
  774. };
  775.  
  776. struct Menu __aligned Menu4 = {
  777.     NULL,    /* next Menu structure */
  778.     162,0,    /* XY origin of Menu hit box relative to screen TopLeft */
  779.     63,0,    /* Menu hit box width and height */
  780.     MENUENABLED,    /* Menu flags */
  781.     "Special",    /* text of Menu name */
  782.     &MenuItem1    /* MenuItem linked list pointer */
  783. };
  784.  
  785. struct IntuiText __far __aligned IText4cc = {
  786.     MENUPEN,1,JAM1,//TBLOCKPEN,1,COMPLEMENT,    /* front and back text pens, drawmode and fill byte */
  787.     19,0,    /* XY origin relative to container TopLeft */
  788.     &TOPAZ80,    /* font pointer or NULL for default */
  789.     "Easy",    /* pointer to text */
  790.     NULL    /* next IntuiText structure */
  791. };
  792.  
  793. struct MenuItem __aligned MenuItem8cc = {
  794.     NULL,    /* next MenuItem structure */
  795.     0,80,    /* XY of Item hitbox relative to TopLeft of parent hitbox */
  796.     123,8,    /* hit box width and height */
  797.     CHECKIT+MENUTOGGLE+ITEMTEXT+COMMSEQ+ITEMENABLED+HIGHCOMP,    /* Item flags */
  798.     EXCLUDE_PATT^(0x400),    /* each bit mutually-excludes a same-level Item */
  799.     (APTR)&IText4cc,    /* Item render  (IntuiText or Image or NULL) */
  800.     NULL,    /* Select render */
  801.     'E',    /* alternate command-key */
  802.     NULL,    /* SubItem list */
  803.     MENUNULL    /* filled in by Intuition for drag selections */
  804. };
  805.  
  806. struct IntuiText __far __aligned IText4dd = {
  807.     MENUPEN,1,JAM1,//TBLOCKPEN,1,COMPLEMENT,    /* front and back text pens, drawmode and fill byte */
  808.     19,0,    /* XY origin relative to container TopLeft */
  809.     &TOPAZ80,    /* font pointer or NULL for default */
  810.     "Intrmdt",    /* pointer to text */
  811.     NULL    /* next IntuiText structure */
  812. };
  813.  
  814. struct MenuItem __aligned MenuItem8dd = {
  815.     &MenuItem8cc,    /* next MenuItem structure */
  816.     0,72,    /* XY of Item hitbox relative to TopLeft of parent hitbox */
  817.     123,8,    /* hit box width and height */
  818.     CHECKIT+MENUTOGGLE+ITEMTEXT+COMMSEQ+ITEMENABLED+HIGHCOMP,    /* Item flags */
  819.     EXCLUDE_PATT^(0x200),    /* each bit mutually-excludes a same-level Item */
  820.     (APTR)&IText4dd,    /* Item render  (IntuiText or Image or NULL) */
  821.     NULL,    /* Select render */
  822.     'I',    /* alternate command-key */
  823.     NULL,    /* SubItem list */
  824.     MENUNULL    /* filled in by Intuition for drag selections */
  825. };
  826.  
  827. struct IntuiText __far __aligned IText4ee = {
  828.     MENUPEN,1,JAM1,//TBLOCKPEN,1,COMPLEMENT,    /* front and back text pens, drawmode and fill byte */
  829.     19,0,    /* XY origin relative to container TopLeft */
  830.     &TOPAZ80,    /* font pointer or NULL for default */
  831.     "Advancd",    /* pointer to text */
  832.     NULL    /* next IntuiText structure */
  833. };
  834.  
  835. struct MenuItem __aligned MenuItem8ee = {
  836.     &MenuItem8dd,    /* next MenuItem structure */
  837.     0,64,    /* XY of Item hitbox relative to TopLeft of parent hitbox */
  838.     123,8,    /* hit box width and height */
  839.     CHECKED+CHECKIT+MENUTOGGLE+ITEMTEXT+COMMSEQ+HIGHCOMP,    /* Item flags */
  840.     EXCLUDE_PATT^(0x100),    /* each bit mutually-excludes a same-level Item */
  841.     (APTR)&IText4ee,    /* Item render  (IntuiText or Image or NULL) */
  842.     NULL,    /* Select render */
  843.     'A',    /* alternate command-key */
  844.     NULL,    /* SubItem list */
  845.     MENUNULL    /* filled in by Intuition for drag selections */
  846. };
  847.  
  848. struct IntuiText __far __aligned IText4aa = {
  849.     MENUPEN,1,JAM1,//TBLOCKPEN,1,COMPLEMENT,    /* front and back text pens, drawmode and fill byte */
  850.     19,0,    /* XY origin relative to container TopLeft */
  851.     &TOPAZ80,    /* font pointer or NULL for default */
  852.     "Supvsr",    /* pointer to text */
  853.     NULL    /* next IntuiText structure */
  854. };
  855.  
  856. struct MenuItem __aligned MenuItem8aa = {
  857.     &MenuItem8ee,    /* next MenuItem structure */
  858.     0,56,    /* XY of Item hitbox relative to TopLeft of parent hitbox */
  859.     123,8,    /* hit box width and height */
  860.     CHECKIT+MENUTOGGLE+ITEMTEXT+COMMSEQ+/*ITEMENABLED+*/HIGHCOMP,    /* Item flags */
  861.     0,    /* each bit mutually-excludes a same-level Item */
  862.     (APTR)&IText4aa,    /* Item render  (IntuiText or Image or NULL) */
  863.     NULL,    /* Select render */
  864.     'Y',    /* alternate command-key */
  865.     NULL,    /* SubItem list */
  866.     MENUNULL    /* filled in by Intuition for drag selections */
  867. };
  868.  
  869. struct IntuiText __far __aligned IText4ab = {
  870.     MENUPEN,1,JAM1,//TBLOCKPEN,1,COMPLEMENT,    /* front and back text pens, drawmode and fill byte */
  871.     19,0,    /* XY origin relative to container TopLeft */
  872.     &TOPAZ80,    /* font pointer or NULL for default */
  873.     "Book",    /* pointer to text */
  874.     NULL    /* next IntuiText structure */
  875. };
  876.  
  877. struct MenuItem __aligned MenuItem8ab = {
  878.       &MenuItem8aa,    /* next MenuItem structure */
  879.     0,48,    /* XY of Item hitbox relative to TopLeft of parent hitbox */
  880.     123,8,    /* hit box width and height */
  881.     CHECKIT+CHECKED+MENUTOGGLE+ITEMTEXT+COMMSEQ+/*ITEMENABLED+*/HIGHCOMP,    /* Item flags */
  882.     0,    /* each bit mutually-excludes a same-level Item */
  883.     (APTR)&IText4ab,    /* Item render  (IntuiText or Image or NULL) */
  884.     NULL,    /* Select render */
  885.     'B',    /* alternate command-key */
  886.     NULL,    /* SubItem list */
  887.     MENUNULL    /* filled in by Intuition for drag selections */
  888. };
  889.  
  890. struct IntuiText __far __aligned IText4a = {
  891.     MENUPEN,1,JAM1,//TBLOCKPEN,1,COMPLEMENT,    /* front and back text pens, drawmode and fill byte */
  892.     19,0,    /* XY origin relative to container TopLeft */
  893.     &TOPAZ80,    /* font pointer or NULL for default */
  894.     "ShwThnk",    /* pointer to text */
  895.     NULL    /* next IntuiText structure */
  896. };
  897.  
  898. struct MenuItem __aligned MenuItem8a = {
  899.     &MenuItem8ab,    /* next MenuItem structure */
  900.     0,40,    /* XY of Item hitbox relative to TopLeft of parent hitbox */
  901.     123,8,    /* hit box width and height */
  902.     CHECKIT+MENUTOGGLE+ITEMTEXT+COMMSEQ+/*ITEMENABLED+*/HIGHCOMP,    /* Item flags */
  903.     0,    /* each bit mutually-excludes a same-level Item */
  904.     (APTR)&IText4a,    /* Item render  (IntuiText or Image or NULL) */
  905.     NULL,    /* Select render */
  906.     'V',    /* alternate command-key */
  907.     NULL,    /* SubItem list */
  908.     MENUNULL    /* filled in by Intuition for drag selections */
  909. };
  910.  
  911. struct IntuiText __far __aligned IText4 = {
  912.     MENUPEN,1,JAM1,//TBLOCKPEN,1,COMPLEMENT,    /* front and back text pens, drawmode and fill byte */
  913.     19,0,    /* XY origin relative to container TopLeft */
  914.     &TOPAZ80,    /* font pointer or NULL for default */
  915.     "Thinking",    /* pointer to text */
  916.     NULL    /* next IntuiText structure */
  917. };
  918.  
  919. struct MenuItem __aligned MenuItem8 = {
  920.     &MenuItem8a,    /* next MenuItem structure */
  921.     0,32,    /* XY of Item hitbox relative to TopLeft of parent hitbox */
  922.     123,8,    /* hit box width and height */
  923.     CHECKIT+MENUTOGGLE+ITEMTEXT+COMMSEQ/*+ITEMENABLED*/+HIGHCOMP,    /* Item flags */
  924.     0,    /* each bit mutually-excludes a same-level Item */
  925.     (APTR)&IText4,    /* Item render  (IntuiText or Image or NULL) */
  926.     NULL,    /* Select render */
  927.     'T',    /* alternate command-key */
  928.     NULL,    /* SubItem list */
  929.     MENUNULL    /* filled in by Intuition for drag selections */
  930. };
  931.  
  932. struct IntuiText __far __aligned IText5 = {
  933.     MENUPEN,1,JAM1,//TBLOCKPEN,1,COMPLEMENT,    /* front and back text pens, drawmode and fill byte */
  934.     0,0,    /* XY origin relative to container TopLeft */
  935.     &TOPAZ80,    /* font pointer or NULL for default */
  936.     "Undo",    /* pointer to text */
  937.     NULL    /* next IntuiText structure */
  938. };
  939.  
  940. struct MenuItem __aligned MenuItem7 = {
  941.     &MenuItem8,    /* next MenuItem structure */
  942.     0,24,    /* XY of Item hitbox relative to TopLeft of parent hitbox */
  943.     123,8,    /* hit box width and height */
  944.     ITEMTEXT+COMMSEQ+ITEMENABLED+HIGHCOMP,    /* Item flags */
  945.     0,    /* each bit mutually-excludes a same-level Item */
  946.     (APTR)&IText5,    /* Item render  (IntuiText or Image or NULL) */
  947.     NULL,    /* Select render */
  948.     'U',    /* alternate command-key */
  949.     NULL,    /* SubItem list */
  950.     MENUNULL    /* filled in by Intuition for drag selections */
  951. };
  952.  
  953. struct IntuiText __far __aligned IText6 = {
  954.     MENUPEN,1,JAM1,//TBLOCKPEN,1,COMPLEMENT,    /* front and back text pens, drawmode and fill byte */
  955.     0,0,    /* XY origin relative to container TopLeft */
  956.     &TOPAZ80,    /* font pointer or NULL for default */
  957.     "Move Now",    /* pointer to text */
  958.     NULL    /* next IntuiText structure */
  959. };
  960.  
  961. struct MenuItem __aligned MenuItem6 = {
  962.     &MenuItem7,    /* next MenuItem structure */
  963.     0,16,    /* XY of Item hitbox relative to TopLeft of parent hitbox */
  964.     123,8,    /* hit box width and height */
  965.     ITEMTEXT+COMMSEQ+/*ITEMENABLED+*/HIGHCOMP,    /* Item flags */
  966.     0,    /* each bit mutually-excludes a same-level Item */
  967.     (APTR)&IText6,    /* Item render  (IntuiText or Image or NULL) */
  968.     NULL,    /* Select render */
  969.     'M',    /* alternate command-key */
  970.     NULL,    /* SubItem list */
  971.     MENUNULL    /* filled in by Intuition for drag selections */
  972. };
  973.  
  974. struct IntuiText __far __aligned IText7 = {
  975.     MENUPEN,1,JAM1,//TBLOCKPEN,1,COMPLEMENT,    /* front and back text pens, drawmode and fill byte */
  976.     0,0,    /* XY origin relative to container TopLeft */
  977.     &TOPAZ80,    /* font pointer or NULL for default */
  978.     "AutoPlay",    /* pointer to text */
  979.     NULL    /* next IntuiText structure */
  980. };
  981.  
  982. struct MenuItem __aligned MenuItem5 = {
  983.     &MenuItem6,    /* next MenuItem structure */
  984.     0,8,    /* XY of Item hitbox relative to TopLeft of parent hitbox */
  985.     123,8,    /* hit box width and height */
  986.     ITEMTEXT+ITEMENABLED+HIGHCOMP,    /* Item flags */
  987.     0,    /* each bit mutually-excludes a same-level Item */
  988.     (APTR)&IText7,    /* Item render  (IntuiText or Image or NULL) */
  989.     NULL,    /* Select render */
  990.     NULL,    /* alternate command-key */
  991.     NULL,    /* SubItem list */
  992.     MENUNULL    /* filled in by Intuition for drag selections */
  993. };
  994.  
  995. struct IntuiText __far __aligned IText8 = {
  996.     MENUPEN,1,JAM1,//TBLOCKPEN,1,COMPLEMENT,    /* front and back text pens, drawmode and fill byte */
  997.     0,0,    /* XY origin relative to container TopLeft */
  998.     &TOPAZ80,    /* font pointer or NULL for default */
  999.     "Swap Sides",    /* pointer to text */
  1000.     NULL    /* next IntuiText structure */
  1001. };
  1002.  
  1003. struct MenuItem __aligned MenuItem4 = {
  1004.     &MenuItem5,    /* next MenuItem structure */
  1005.     0,0,    /* XY of Item hitbox relative to TopLeft of parent hitbox */
  1006.     123,8,    /* hit box width and height */
  1007.     ITEMTEXT+COMMSEQ+ITEMENABLED+HIGHCOMP,    /* Item flags */
  1008.     0,    /* each bit mutually-excludes a same-level Item */
  1009.     (APTR)&IText8,    /* Item render  (IntuiText or Image or NULL) */
  1010.     NULL,    /* Select render */
  1011.     'S',    /* alternate command-key */
  1012.     NULL,    /* SubItem list */
  1013.     MENUNULL    /* filled in by Intuition for drag selections */
  1014. };
  1015.  
  1016. struct Menu __aligned Menu3 = {
  1017.     &Menu4,    /* next Menu structure */
  1018.     92,0,    /* XY origin of Menu hit box relative to screen TopLeft */
  1019.     63,0,    /* Menu hit box width and height */
  1020.     MENUENABLED,    /* Menu flags */
  1021.     "Control",    /* text of Menu name */
  1022.     &MenuItem4    /* MenuItem linked list pointer */
  1023. };
  1024.  
  1025. struct IntuiText __far __aligned IText9 = {
  1026.     MENUPEN,1,JAM1,//TBLOCKPEN,1,COMPLEMENT,    /* front and back text pens, drawmode and fill byte */
  1027.     0,0,    /* XY origin relative to container TopLeft */
  1028.     &TOPAZ80,    /* font pointer or NULL for default */
  1029.     "ReverseBoard",    /* pointer to text */
  1030.     NULL    /* next IntuiText structure */
  1031. };
  1032.  
  1033. struct MenuItem __aligned MenuItem11 = {
  1034.     NULL,    /* next MenuItem structure */
  1035.     0,16,    /* XY of Item hitbox relative to TopLeft of parent hitbox */
  1036.     96,8,    /* hit box width and height */
  1037.     ITEMTEXT+/*ITEMENABLED+*/HIGHCOMP,    /* Item flags */
  1038.     0,    /* each bit mutually-excludes a same-level Item */
  1039.     (APTR)&IText9,    /* Item render  (IntuiText or Image or NULL) */
  1040.     NULL,    /* Select render */
  1041.     NULL,    /* alternate command-key */
  1042.     NULL,    /* SubItem list */
  1043.     MENUNULL    /* filled in by Intuition for drag selections */
  1044. };
  1045.  
  1046. struct IntuiText __far __aligned IText10 = {
  1047.     MENUPEN,1,JAM1,//TBLOCKPEN,1,COMPLEMENT,    /* front and back text pens, drawmode and fill byte */
  1048.     19,0,    /* XY origin relative to container TopLeft */
  1049.     &TOPAZ80,    /* font pointer or NULL for default */
  1050.     "Edit Board",    /* pointer to text */
  1051.     NULL    /* next IntuiText structure */
  1052. };
  1053.  
  1054. struct MenuItem __aligned MenuItem10 = {
  1055.     &MenuItem11,    /* next MenuItem structure */
  1056.     0,8,    /* XY of Item hitbox relative to TopLeft of parent hitbox */
  1057.     96,8,    /* hit box width and height */
  1058.     ITEMTEXT+HIGHCOMP+ITEMENABLED,    /* Item flags */
  1059.     0,    /* each bit mutually-excludes a same-level Item */
  1060.     (APTR)&IText10,    /* Item render  (IntuiText or Image or NULL) */
  1061.     NULL,    /* Select render */
  1062.     NULL,    /* alternate command-key */
  1063.     NULL,    /* SubItem list */
  1064.     MENUNULL    /* filled in by Intuition for drag selections */
  1065. };
  1066.  
  1067. struct IntuiText __far __aligned IText11 = {
  1068.     MENUPEN,1,JAM1,//TBLOCKPEN,1,COMPLEMENT,    /* front and back text pens, drawmode and fill byte */
  1069.     19,0,    /* XY origin relative to container TopLeft */
  1070.     &TOPAZ80,    /* font pointer or NULL for default */
  1071.     "2-D",    /* pointer to text */
  1072.     NULL    /* next IntuiText structure */
  1073. };
  1074.  
  1075. struct MenuItem __aligned MenuItem9 = {
  1076.     &MenuItem10,    /* next MenuItem structure */
  1077.     0,0,    /* XY of Item hitbox relative to TopLeft of parent hitbox */
  1078.     96,8,    /* hit box width and height */
  1079.     CHECKED+CHECKIT+ITEMTEXT+ITEMENABLED+HIGHCOMP,    /* Item flags */
  1080.     0,    /* each bit mutually-excludes a same-level Item */
  1081.     (APTR)&IText11,    /* Item render  (IntuiText or Image or NULL) */
  1082.     NULL,    /* Select render */
  1083.     NULL,    /* alternate command-key */
  1084.     NULL,    /* SubItem list */
  1085.     MENUNULL    /* filled in by Intuition for drag selections */
  1086. };
  1087.  
  1088. struct Menu __aligned Menu2 = {
  1089.     &Menu3,    /* next Menu structure */
  1090.     46,0,    /* XY origin of Menu hit box relative to screen TopLeft */
  1091.     39,0,    /* Menu hit box width and height */
  1092.     MENUENABLED,    /* Menu flags */
  1093.     "View",    /* text of Menu name */
  1094.     &MenuItem9    /* MenuItem linked list pointer */
  1095. };
  1096.  
  1097. struct IntuiText __far __aligned IText12 = {
  1098.     MENUPEN,1,JAM1,//TBLOCKPEN,1,COMPLEMENT,    /* front and back text pens, drawmode and fill byte */
  1099.     0,0,    /* XY origin relative to container TopLeft */
  1100.     &TOPAZ80,    /* font pointer or NULL for default */
  1101.     "Quit",    /* pointer to text */
  1102.     NULL    /* next IntuiText structure */
  1103. };
  1104.  
  1105. struct MenuItem __aligned MenuItem15 = {
  1106.     NULL,    /* next MenuItem structure */
  1107.     0,40,    /* XY of Item hitbox relative to TopLeft of parent hitbox */
  1108.     72,8,    /* hit box width and height */
  1109.     ITEMTEXT+COMMSEQ+ITEMENABLED+HIGHCOMP,    /* Item flags */
  1110.     0,    /* each bit mutually-excludes a same-level Item */
  1111.     (APTR)&IText12,    /* Item render  (IntuiText or Image or NULL) */
  1112.     NULL,    /* Select render */
  1113.     'Q',    /* alternate command-key */
  1114.     NULL,    /* SubItem list */
  1115.     MENUNULL    /* filled in by Intuition for drag selections */
  1116. };
  1117.  
  1118. struct IntuiText __far __aligned IText13a = {
  1119.     MENUPEN,1,JAM1,//TBLOCKPEN,1,COMPLEMENT,    /* front and back text pens, drawmode and fill byte */
  1120.     0,0,    /* XY origin relative to container TopLeft */
  1121.     &TOPAZ80,    /* font pointer or NULL for default */
  1122.     "List Game",    /* pointer to text */
  1123.     NULL    /* next IntuiText structure */
  1124. };
  1125.  
  1126. struct MenuItem __aligned MenuItem14a = {
  1127.     &MenuItem15,    /* next MenuItem structure */
  1128.     0,32,    /* XY of Item hitbox relative to TopLeft of parent hitbox */
  1129.     72,8,    /* hit box width and height */
  1130.     ITEMTEXT+ITEMENABLED+HIGHCOMP,    /* Item flags */
  1131.     0,    /* each bit mutually-excludes a same-level Item */
  1132.     (APTR)&IText13a,/* Item render  (IntuiText or Image or NULL) */
  1133.     NULL,    /* Select render */
  1134.     NULL,    /* alternate command-key */
  1135.     NULL,    /* SubItem list */
  1136.     MENUNULL    /* filled in by Intuition for drag selections */
  1137. };
  1138.  
  1139. struct IntuiText __far __aligned IText13 = {
  1140.     MENUPEN,1,JAM1,//TBLOCKPEN,1,COMPLEMENT,    /* front and back text pens, drawmode and fill byte */
  1141.     0,0,    /* XY origin relative to container TopLeft */
  1142.     &TOPAZ80,    /* font pointer or NULL for default */
  1143.     "Save Game",    /* pointer to text */
  1144.     NULL    /* next IntuiText structure */
  1145. };
  1146.  
  1147. struct MenuItem __aligned MenuItem14 = {
  1148.     &MenuItem14a,    /* next MenuItem structure */
  1149.     0,24,    /* XY of Item hitbox relative to TopLeft of parent hitbox */
  1150.     72,8,    /* hit box width and height */
  1151.     ITEMTEXT+ITEMENABLED+HIGHCOMP,    /* Item flags */
  1152.     0,    /* each bit mutually-excludes a same-level Item */
  1153.     (APTR)&IText13,    /* Item render  (IntuiText or Image or NULL) */
  1154.     NULL,    /* Select render */
  1155.     NULL,    /* alternate command-key */
  1156.     NULL,    /* SubItem list */
  1157.     MENUNULL    /* filled in by Intuition for drag selections */
  1158. };
  1159.  
  1160. struct IntuiText __far __aligned IText14 = {
  1161.     MENUPEN,1,JAM1,//TBLOCKPEN,1,COMPLEMENT,    /* front and back text pens, drawmode and fill byte */
  1162.     0,0,    /* XY origin relative to container TopLeft */
  1163.     &TOPAZ80,    /* font pointer or NULL for default */
  1164.     "Load Game",    /* pointer to text */
  1165.     NULL    /* next IntuiText structure */
  1166. };
  1167.  
  1168. struct MenuItem __aligned MenuItem13 = {
  1169.     &MenuItem14,    /* next MenuItem structure */
  1170.     0,16,    /* XY of Item hitbox relative to TopLeft of parent hitbox */
  1171.     72,8,    /* hit box width and height */
  1172.     ITEMTEXT+ITEMENABLED+HIGHCOMP,    /* Item flags */
  1173.     0,    /* each bit mutually-excludes a same-level Item */
  1174.     (APTR)&IText14,    /* Item render  (IntuiText or Image or NULL) */
  1175.     NULL,    /* Select render */
  1176.     NULL,    /* alternate command-key */
  1177.     NULL,    /* SubItem list */
  1178.     MENUNULL    /* filled in by Intuition for drag selections */
  1179. };
  1180.  
  1181. struct MenuItem __aligned MenuItem28 = {
  1182.     &MenuItem13,    /* next MenuItem structure */
  1183.     0,8,    /* XY of Item hitbox relative to TopLeft of parent hitbox */
  1184.     72,8,    /* hit box width and height */
  1185.     ITEMTEXT+ITEMENABLED+HIGHCOMP,    /* Item flags */
  1186.     0,    /* each bit mutually-excludes a same-level Item */
  1187.     (APTR)&IText37,    /* Item render  (IntuiText or Image or NULL) */
  1188.     NULL,    /* Select render */
  1189.     NULL,    /* alternate command-key */
  1190.     NULL,    /* SubItem list */
  1191.     MENUNULL    /* filled in by Intuition for drag selections */
  1192. };
  1193.  
  1194. struct IntuiText __far __aligned IText15 = {
  1195.     MENUPEN,1,JAM1,//TBLOCKPEN,1,COMPLEMENT,    /* front and back text pens, drawmode and fill byte */
  1196.     0,0,    /* XY origin relative to container TopLeft */
  1197.     &TOPAZ80,    /* font pointer or NULL for default */
  1198.     "About..",    /* pointer to text */
  1199.     NULL    /* next IntuiText structure */
  1200. };
  1201.  
  1202. struct MenuItem __aligned MenuItem12 = {
  1203.     &MenuItem28,    /* next MenuItem structure */
  1204.     0,0,    /* XY of Item hitbox relative to TopLeft of parent hitbox */
  1205.     72,8,    /* hit box width and height */
  1206.     ITEMTEXT+ITEMENABLED+HIGHCOMP,    /* Item flags */
  1207.     0,    /* each bit mutually-excludes a same-level Item */
  1208.     (APTR)&IText15,    /* Item render  (IntuiText or Image or NULL) */
  1209.     NULL,    /* Select render */
  1210.     NULL,    /* alternate command-key */
  1211.     NULL,    /* SubItem list */
  1212.     MENUNULL    /* filled in by Intuition for drag selections */
  1213. };
  1214.  
  1215. struct Menu __aligned Menu1 = {
  1216.     &Menu2,    /* next Menu structure */
  1217.     0,0,    /* XY origin of Menu hit box relative to screen TopLeft */
  1218.     39,0,    /* Menu hit box width and height */
  1219.     MENUENABLED,    /* Menu flags */
  1220.     "File",    /* text of Menu name */
  1221.     &MenuItem12    /* MenuItem linked list pointer */
  1222. };
  1223.  
  1224. #define MenuList1 Menu1
  1225.  
  1226. struct NewWindow __aligned NewWindowStructure1 = {
  1227.     0,0,    /* window XY origin relative to TopLeft of screen */
  1228.     WIDTH,THEIGHT,    /* window width and height */
  1229.     0,TBLOCKPEN,    /* detail and block pens */
  1230.     MOUSEBUTTONS|MENUPICK|RAWKEY,    /* IDCMP flags */
  1231.     BACKDROP+BORDERLESS+ACTIVATE+NOCAREREFRESH,    /* other window flags */
  1232.     NULL,    /* first gadget in gadget list */
  1233.     NULL,    /* custom CHECKMARK imagery */
  1234.     " ",    /* window title */
  1235.     NULL,    /* custom screen pointer */
  1236.     NULL,    /* custom bitmap */
  1237.     WIDTH,THEIGHT,    /* minimum width and height */
  1238.     0xffff,0xffff,    /* maximum width and height */
  1239.     CUSTOMSCREEN    /* destination screen type */
  1240. };
  1241.  
  1242. SHORT __far __aligned BorderVectors1[] = {
  1243.     0,0,
  1244.     81,0,
  1245.     81,38,
  1246.     0,38,
  1247.     0,0
  1248. };
  1249. struct Border __far __aligned Border1 = {
  1250.     -1,-1,    /* XY origin relative to container TopLeft */
  1251.     TBLOCKPEN,0,JAM1,    /* front pen, back pen and drawmode */
  1252.     5,    /* number of XY vectors */
  1253.     BorderVectors1,    /* pointer to XY vectors */
  1254.     NULL    /* next border in list */
  1255. };
  1256.  
  1257. struct IntuiText __far __aligned IText16 = {
  1258.     TBLOCKPEN,0,JAM2,    /* front and back text pens, drawmode and fill byte */
  1259.     31,15,    /* XY origin relative to container TopLeft */
  1260.     NULL,    /* font pointer or NULL for default */
  1261.     "OK",    /* pointer to text */
  1262.     NULL    /* next IntuiText structure */
  1263. };
  1264.  
  1265. struct Gadget __far __aligned Gadget1 = {
  1266.     NULL,    /* next gadget */
  1267.     155,233,    /* origin XY of hit box relative to window TopLeft */
  1268.     80,37,    /* hit box width and height */
  1269.     NULL,    /* gadget flags */
  1270.     RELVERIFY,    /* activation flags */
  1271.     BOOLGADGET,    /* gadget type flags */
  1272.     (APTR)&Border1,    /* gadget border or image to be rendered */
  1273.     NULL,    /* alternate imagery for selection */
  1274.     &IText16,    /* first IntuiText structure */
  1275.     NULL,    /* gadget mutual-exclude long word */
  1276.     NULL,    /* SpecialInfo structure */
  1277.     NULL,    /* user-definable data */
  1278.     NULL    /* pointer to user-definable data */
  1279. };
  1280.  
  1281. #define GadgetList2 Gadget1
  1282.  
  1283. struct IntuiText __far __aligned IText22 = {
  1284.     TBLOCKPEN,0,JAM2,    /* front and back text pens, drawmode and fill byte */
  1285.     143,130,    /* XY origin relative to container TopLeft */
  1286.     NULL,    /* font pointer or NULL for default */
  1287.     "of Computers.",    /* pointer to text */
  1288.     NULL    /* next IntuiText structure */
  1289. };
  1290.  
  1291. struct IntuiText __far __aligned IText21 = {
  1292.     TBLOCKPEN,0,JAM2,    /* front and back text pens, drawmode and fill byte */
  1293.     115,117,    /* XY origin relative to container TopLeft */
  1294.     NULL,    /* font pointer or NULL for default */
  1295.     "For the Amiga Family",    /* pointer to text */
  1296.     &IText22    /* next IntuiText structure */
  1297. };
  1298.  
  1299. struct IntuiText __far __aligned IText20 = {
  1300.     TBLOCKPEN,0,JAM2,    /* front and back text pens, drawmode and fill byte */
  1301.     104,102,    /* XY origin relative to container TopLeft */
  1302.     NULL,    /* font pointer or NULL for default */
  1303.     "Chess Program Available",    /* pointer to text */
  1304.     &IText21    /* next IntuiText structure */
  1305. };
  1306.  
  1307. struct IntuiText __far __aligned IText19 = {
  1308.     TBLOCKPEN,0,JAM2,    /* front and back text pens, drawmode and fill byte */
  1309.     108,87,    /* XY origin relative to container TopLeft */
  1310.     NULL,    /* font pointer or NULL for default */
  1311.     "The strongest Playing",    /* pointer to text */
  1312.     &IText20    /* next IntuiText structure */
  1313. };
  1314.  
  1315. struct IntuiText __far __aligned IText18 = {
  1316.     TBLOCKPEN,0,JAM2,    /* front and back text pens, drawmode and fill byte */
  1317.     126,31,    /* XY origin relative to container TopLeft */
  1318.     NULL,    /* font pointer or NULL for default */
  1319.     "by Roger Uzun",    /* pointer to text */
  1320.     &IText19    /* next IntuiText structure */
  1321. };
  1322.  
  1323. struct IntuiText __far __aligned IText17 = {
  1324.     TBLOCKPEN,0,JAM2,    /* front and back text pens, drawmode and fill byte */
  1325.     131,18,    /* XY origin relative to container TopLeft */
  1326.     NULL,    /* font pointer or NULL for default */
  1327.     VERSTRING,    /* pointer to text */
  1328.     &IText18    /* next IntuiText structure */
  1329. };
  1330.  
  1331. struct NewWindow __far __aligned NewWindowStructure2 = {
  1332.     125,30,    /* window XY origin relative to TopLeft of screen */
  1333.     390,290,    /* window width and height */
  1334.     0,TBLOCKPEN,    /* detail and block pens */
  1335.     VANILLAKEY|GADGETUP,    /* IDCMP flags */
  1336.     SIMPLE_REFRESH+NOCAREREFRESH+ACTIVATE,    /* other window flags */
  1337.     &Gadget1,    /* first gadget in gadget list */
  1338.     NULL,    /* custom CHECKMARK imagery */
  1339. #ifdef _M68040
  1340.     "UChess Pro",    /* window title */
  1341. #else
  1342. #ifndef TINYCHESS
  1343.     "UChess Jr.",    /* window title */
  1344. #else
  1345.     "UChess Tiny",    /* window title */
  1346. #endif
  1347. #endif
  1348.     NULL,    /* custom screen pointer */
  1349.     NULL,    /* custom bitmap */
  1350.     5,5,    /* minimum width and height */
  1351.     0xffff,0xffff,    /* maximum width and height */
  1352.     CUSTOMSCREEN    /* destination screen type */
  1353. };
  1354.  
  1355.  
  1356. SHORT __far __aligned aBorderVectors1[] = {
  1357.     0,0,
  1358.     77,0,
  1359.     77,25,
  1360.     0,25,
  1361.     0,0
  1362. };
  1363. struct Border __far __aligned aBorder1 = {
  1364.     -1,-1,    /* XY origin relative to container TopLeft */
  1365.     TBLOCKPEN,0,JAM1,    /* front pen, back pen and drawmode */
  1366.     5,    /* number of XY vectors */
  1367.     aBorderVectors1,    /* pointer to XY vectors */
  1368.     NULL    /* next border in list */
  1369. };
  1370.  
  1371. struct IntuiText __far __aligned aIText1 = {
  1372.     TBLOCKPEN,0,JAM2,    /* front and back text pens, drawmode and fill byte */
  1373.     16,8,    /* XY origin relative to container TopLeft */
  1374.     NULL,    /* font pointer or NULL for default */
  1375.     "KNIGHT",    /* pointer to text */
  1376.     NULL    /* next IntuiText structure */
  1377. };
  1378.  
  1379. struct Gadget __far __aligned aGadget4 = {
  1380.     NULL,    /* next gadget */
  1381.     55,124,    /* origin XY of hit box relative to window TopLeft */
  1382.     76,24,    /* hit box width and height */
  1383.     NULL,    /* gadget flags */
  1384.     RELVERIFY,    /* activation flags */
  1385.     BOOLGADGET,    /* gadget type flags */
  1386.     (APTR)&aBorder1,    /* gadget border or image to be rendered */
  1387.     NULL,    /* alternate imagery for selection */
  1388.     &aIText1,    /* first IntuiText structure */
  1389.     NULL,    /* gadget mutual-exclude long word */
  1390.     NULL,    /* SpecialInfo structure */
  1391.     NULL,    /* user-definable data */
  1392.     NULL    /* pointer to user-definable data */
  1393. };
  1394.  
  1395. SHORT __far __aligned aBorderVectors2[] = {
  1396.     0,0,
  1397.     77,0,
  1398.     77,25,
  1399.     0,25,
  1400.     0,0
  1401. };
  1402. struct Border __far __aligned aBorder2 = {
  1403.     -1,-1,    /* XY origin relative to container TopLeft */
  1404.     TBLOCKPEN,0,JAM1,    /* front pen, back pen and drawmode */
  1405.     5,    /* number of XY vectors */
  1406.     aBorderVectors2,    /* pointer to XY vectors */
  1407.     NULL    /* next border in list */
  1408. };
  1409.  
  1410. struct IntuiText __far __aligned aIText2 = {
  1411.     TBLOCKPEN,0,JAM2,    /* front and back text pens, drawmode and fill byte */
  1412.     15,8,    /* XY origin relative to container TopLeft */
  1413.     NULL,    /* font pointer or NULL for default */
  1414.     "BISHOP",    /* pointer to text */
  1415.     NULL    /* next IntuiText structure */
  1416. };
  1417.  
  1418. struct Gadget __far __aligned aGadget3 = {
  1419.     &aGadget4,    /* next gadget */
  1420.     55,92,    /* origin XY of hit box relative to window TopLeft */
  1421.     76,24,    /* hit box width and height */
  1422.     NULL,    /* gadget flags */
  1423.     RELVERIFY,    /* activation flags */
  1424.     BOOLGADGET,    /* gadget type flags */
  1425.     (APTR)&aBorder2,    /* gadget border or image to be rendered */
  1426.     NULL,    /* alternate imagery for selection */
  1427.     &aIText2,    /* first IntuiText structure */
  1428.     NULL,    /* gadget mutual-exclude long word */
  1429.     NULL,    /* SpecialInfo structure */
  1430.     NULL,    /* user-definable data */
  1431.     NULL    /* pointer to user-definable data */
  1432. };
  1433.  
  1434. SHORT __far __aligned aBorderVectors3[] = {
  1435.     0,0,
  1436.     77,0,
  1437.     77,25,
  1438.     0,25,
  1439.     0,0
  1440. };
  1441. struct Border __far __aligned aBorder3 = {
  1442.     -1,-1,    /* XY origin relative to container TopLeft */
  1443.     TBLOCKPEN,0,JAM1,    /* front pen, back pen and drawmode */
  1444.     5,    /* number of XY vectors */
  1445.     aBorderVectors3,    /* pointer to XY vectors */
  1446.     NULL    /* next border in list */
  1447. };
  1448.  
  1449. struct IntuiText __far __aligned aIText3 = {
  1450.     TBLOCKPEN,0,JAM2,    /* front and back text pens, drawmode and fill byte */
  1451.     19,8,    /* XY origin relative to container TopLeft */
  1452.     NULL,    /* font pointer or NULL for default */
  1453.     "ROOK",    /* pointer to text */
  1454.     NULL    /* next IntuiText structure */
  1455. };
  1456.  
  1457. struct Gadget __far __aligned aGadget2 = {
  1458.     &aGadget3,    /* next gadget */
  1459.     55,60,    /* origin XY of hit box relative to window TopLeft */
  1460.     76,24,    /* hit box width and height */
  1461.     NULL,    /* gadget flags */
  1462.     RELVERIFY,    /* activation flags */
  1463.     BOOLGADGET,    /* gadget type flags */
  1464.     (APTR)&aBorder3,    /* gadget border or image to be rendered */
  1465.     NULL,    /* alternate imagery for selection */
  1466.     &aIText3,    /* first IntuiText structure */
  1467.     NULL,    /* gadget mutual-exclude long word */
  1468.     NULL,    /* SpecialInfo structure */
  1469.     NULL,    /* user-definable data */
  1470.     NULL    /* pointer to user-definable data */
  1471. };
  1472.  
  1473. SHORT __far __aligned aBorderVectors4[] = {
  1474.     0,0,
  1475.     77,0,
  1476.     77,25,
  1477.     0,25,
  1478.     0,0
  1479. };
  1480. struct Border __far __aligned aBorder4 = {
  1481.     -1,-1,    /* XY origin relative to container TopLeft */
  1482.     TBLOCKPEN,0,JAM1,    /* front pen, back pen and drawmode */
  1483.     5,    /* number of XY vectors */
  1484.     aBorderVectors4,    /* pointer to XY vectors */
  1485.     NULL    /* next border in list */
  1486. };
  1487.  
  1488. struct IntuiText __far __aligned aIText4 = {
  1489.     TBLOCKPEN,0,JAM2,    /* front and back text pens, drawmode and fill byte */
  1490.     16,8,    /* XY origin relative to container TopLeft */
  1491.     NULL,    /* font pointer or NULL for default */
  1492.     "QUEEN",    /* pointer to text */
  1493.     NULL    /* next IntuiText structure */
  1494. };
  1495.  
  1496. struct Gadget __far __aligned aGadget1 = {
  1497.     &aGadget2,    /* next gadget */
  1498.     55,28,    /* origin XY of hit box relative to window TopLeft */
  1499.     76,24,    /* hit box width and height */
  1500.     NULL,    /* gadget flags */
  1501.     RELVERIFY,    /* activation flags */
  1502.     BOOLGADGET,    /* gadget type flags */
  1503.     (APTR)&aBorder4,    /* gadget border or image to be rendered */
  1504.     NULL,    /* alternate imagery for selection */
  1505.     &aIText4,    /* first IntuiText structure */
  1506.     NULL,    /* gadget mutual-exclude long word */
  1507.     NULL,    /* SpecialInfo structure */
  1508.     NULL,    /* user-definable data */
  1509.     NULL    /* pointer to user-definable data */
  1510. };
  1511.  
  1512.  
  1513. struct IntuiText __far __aligned aIText5 = {
  1514.     TBLOCKPEN,0,JAM2,    /* front and back text pens, drawmode and fill byte */
  1515.     33,14,    /* XY origin relative to container TopLeft */
  1516.     &TOPAZ80,    /* font pointer or NULL for default */
  1517.     "Promote Pawn to",    /* pointer to text */
  1518.     NULL    /* next IntuiText structure */
  1519. };
  1520.  
  1521.  
  1522. struct NewWindow __aligned NewWindowStructure6 = {
  1523.     220,35,    /* window XY origin relative to TopLeft of screen */
  1524.     200,170,    /* window width and height */
  1525.     0,TBLOCKPEN,    /* detail and block pens */
  1526.     GADGETUP,    /* IDCMP flags */
  1527.     SIMPLE_REFRESH+ACTIVATE+NOCAREREFRESH,    /* other window flags */
  1528.     &aGadget1,    /* first gadget in gadget list */
  1529.     NULL,    /* custom CHECKMARK imagery */
  1530.     "Promote Piece",    /* window title */
  1531.     NULL,    /* custom screen pointer */
  1532.     NULL,    /* custom bitmap */
  1533.     5,5,    /* minimum width and height */
  1534.     0xffff,0xffff,    /* maximum width and height */
  1535.     CUSTOMSCREEN    /* destination screen type */
  1536. };
  1537.  
  1538. #define MOVENOWMENUNUM 0x42
  1539. #define THINKMENUNUM 0x82
  1540. #define SHOWMENUNUM 0xa2
  1541. #define BOOKMENUNUM 0xc2
  1542. #define SUPERMENUNUM 0xe2
  1543. #define ADVANCEDMENUNUM 0x102
  1544. #define INTERMEDIATEMENUNUM 0x122
  1545. #define EASYMENUNUM 0x142
  1546.  
  1547.  
  1548. SHORT __far __aligned pBorderVectors1[] = {
  1549.     0,0,
  1550.     68,0,
  1551.     68,31,
  1552.     0,31,
  1553.     0,0
  1554. };
  1555. struct Border __far __aligned pBorder1 = {
  1556.     -1,-1,    /* XY origin relative to container TopLeft */
  1557.     TBLOCKPEN,0,JAM1,    /* front pen, back pen and drawmode */
  1558.     5,    /* number of XY vectors */
  1559.     pBorderVectors1,    /* pointer to XY vectors */
  1560.     NULL    /* next border in list */
  1561. };
  1562.  
  1563. struct IntuiText __far __aligned pIText1 = {
  1564.     TBLOCKPEN,0,JAM2,    /* front and back text pens, drawmode and fill byte */
  1565.     13,11,    /* XY origin relative to container TopLeft */
  1566.     &TOPAZ80,    /* font pointer or NULL for default */
  1567.     "DONE",    /* pointer to text */
  1568.     NULL    /* next IntuiText structure */
  1569. };
  1570.  
  1571. struct Gadget __far __aligned pGadget4 = {
  1572.     NULL,    /* next gadget */
  1573.     104,172,    /* origin XY of hit box relative to window TopLeft */
  1574.     67,30,    /* hit box width and height */
  1575.     NULL,    /* gadget flags */
  1576.     RELVERIFY,    /* activation flags */
  1577.     BOOLGADGET,    /* gadget type flags */
  1578.     (APTR)&pBorder1,    /* gadget border or image to be rendered */
  1579.     NULL,    /* alternate imagery for selection */
  1580.     &pIText1,    /* first IntuiText structure */
  1581.     NULL,    /* gadget mutual-exclude long word */
  1582.     NULL,    /* SpecialInfo structure */
  1583.     NULL,    /* user-definable data */
  1584.     NULL    /* pointer to user-definable data */
  1585. };
  1586.  
  1587. SHORT __far __aligned pBorderVectors2[] = {
  1588.     0,0,
  1589.     68,0,
  1590.     68,31,
  1591.     0,31,
  1592.     0,0
  1593. };
  1594. struct Border __far __aligned pBorder2 = {
  1595.     -1,-1,    /* XY origin relative to container TopLeft */
  1596.     TBLOCKPEN,0,JAM1,    /* front pen, back pen and drawmode */
  1597.     5,    /* number of XY vectors */
  1598.     pBorderVectors2,    /* pointer to XY vectors */
  1599.     NULL    /* next border in list */
  1600. };
  1601.  
  1602. struct IntuiText __far __aligned pIText2 = {
  1603.     TBLOCKPEN,0,JAM2,    /* front and back text pens, drawmode and fill byte */
  1604.     117,132,    /* was 13,11 XY origin relative to container TopLeft */
  1605.     &TOPAZ80,    /* font pointer or NULL for default */
  1606.     "WHITE",    /* pointer to text */
  1607.     NULL    /* next IntuiText structure */
  1608. };
  1609.  
  1610. struct IntuiText __far __aligned pIText2a = {
  1611.     TBLOCKPEN,0,JAM2,    /* front and back text pens, drawmode and fill byte */
  1612.     117,132,    /* was 13,11 XY origin relative to container TopLeft */
  1613.     &TOPAZ80,    /* font pointer or NULL for default */
  1614.     "BLACK",    /* pointer to text */
  1615.     NULL    /* next IntuiText structure */
  1616. };
  1617.  
  1618. struct Gadget __far __aligned pGadget3 = {
  1619.     &pGadget4,    /* next gadget */
  1620.     104,121,    /* origin XY of hit box relative to window TopLeft */
  1621.     67,30,    /* hit box width and height */
  1622.     NULL,    /* gadget flags */
  1623.     RELVERIFY,    /* activation flags */
  1624.     BOOLGADGET,    /* gadget type flags */
  1625.     (APTR)&pBorder2,    /* gadget border or image to be rendered */
  1626.     NULL,    /* alternate imagery for selection */
  1627.     NULL,    /* first IntuiText structure */
  1628.     NULL,    /* gadget mutual-exclude long word */
  1629.     NULL,    /* SpecialInfo structure */
  1630.     NULL,    /* user-definable data */
  1631.     NULL    /* pointer to user-definable data */
  1632. };
  1633.  
  1634. SHORT __far __aligned pBorderVectors3[] = {
  1635.     0,0,
  1636.     68,0,
  1637.     68,31,
  1638.     0,31,
  1639.     0,0
  1640. };
  1641. struct Border __far __aligned pBorder3 = {
  1642.     -1,-1,    /* XY origin relative to container TopLeft */
  1643.     TBLOCKPEN,0,JAM1,    /* front pen, back pen and drawmode */
  1644.     5,    /* number of XY vectors */
  1645.     pBorderVectors3,    /* pointer to XY vectors */
  1646.     NULL    /* next border in list */
  1647. };
  1648.  
  1649. struct IntuiText __far __aligned pIText3 = {
  1650.     TBLOCKPEN,0,JAM2,    /* front and back text pens, drawmode and fill byte */
  1651.     0,12,    /* XY origin relative to container TopLeft */
  1652.     &TOPAZ80,    /* font pointer or NULL for default */
  1653.     "Clear BD",    /* pointer to text */
  1654.     NULL    /* next IntuiText structure */
  1655. };
  1656.  
  1657. struct Gadget __far __aligned pGadget2 = {
  1658.     &pGadget3,    /* next gadget */
  1659.     105,82,    /* origin XY of hit box relative to window TopLeft */
  1660.     67,30,    /* hit box width and height */
  1661.     NULL,    /* gadget flags */
  1662.     RELVERIFY,    /* activation flags */
  1663.     BOOLGADGET,    /* gadget type flags */
  1664.     (APTR)&pBorder3,    /* gadget border or image to be rendered */
  1665.     NULL,    /* alternate imagery for selection */
  1666.     &pIText3,    /* first IntuiText structure */
  1667.     NULL,    /* gadget mutual-exclude long word */
  1668.     NULL,    /* SpecialInfo structure */
  1669.     NULL,    /* user-definable data */
  1670.     NULL    /* pointer to user-definable data */
  1671. };
  1672.  
  1673. UBYTE __aligned pppSIBuff[4];
  1674. struct StringInfo __aligned pppSInfo = {
  1675.     pppSIBuff,    /* buffer where text will be edited */
  1676.     NULL,    /* optional undo buffer */
  1677.     0,    /* character position in buffer */
  1678.     4,    /* maximum number of characters to allow */
  1679.     0,    /* first displayed character buffer position */
  1680.     0,0,0,0,0,    /* Intuition initialized and maintained variables */
  1681.     0,    /* Rastport of gadget */
  1682.     0,    /* initial value for integer gadgets */
  1683.     NULL    /* alternate keymap (fill in if you set the flag) */
  1684. };
  1685.  
  1686. SHORT __far __aligned pBorderVectors4[] = {
  1687.     0,0,
  1688.     55,0,
  1689.     55,16, /* was 55,24 and 0, 24 */
  1690.     0,16,
  1691.     0,0
  1692. };
  1693. struct Border __far __aligned pBorder4 = {
  1694.     -1,-1,    /* XY origin relative to container TopLeft */
  1695.     TBLOCKPEN,0,JAM1,    /* front pen, back pen and drawmode */
  1696.     5,    /* number of XY vectors */
  1697.     pBorderVectors4,    /* pointer to XY vectors */
  1698.     NULL    /* next border in list */
  1699. };
  1700.  
  1701. struct Gadget __far __aligned pGadget1 = {
  1702.     &pGadget2,    /* next gadget */
  1703.     180,57,    /* origin XY of hit box relative to window TopLeft */
  1704.     54,15,    /* was 54, 23 hit box width and height */
  1705.     NULL,    /* gadget flags */
  1706.     RELVERIFY,    /* activation flags */
  1707.     STRGADGET,    /* gadget type flags */
  1708.     (APTR)&pBorder4,    /* gadget border or image to be rendered */
  1709.     NULL,    /* alternate imagery for selection */
  1710.     NULL,    /* first IntuiText structure */
  1711.     NULL,    /* gadget mutual-exclude long word */
  1712.     (APTR)&pppSInfo,    /* SpecialInfo structure */
  1713.     NULL,    /* user-definable data */
  1714.     NULL    /* pointer to user-definable data */
  1715. };
  1716.  
  1717. struct IntuiText __far __aligned pIText8a = {
  1718.     TBLOCKPEN,0,JAM2,    /* front and back text pens, drawmode and fill byte */
  1719.     32,44,    /* XY origin relative to container TopLeft */
  1720.     NULL,    /* font pointer or NULL for default */
  1721.     "use space to clr a square",    /* pointer to text */
  1722.     NULL    /* next IntuiText structure */
  1723. };
  1724.  
  1725. struct IntuiText __far __aligned pIText7 = {
  1726.     TBLOCKPEN,0,JAM2,    /* front and back text pens, drawmode and fill byte */
  1727.     26,34,    /* XY origin relative to container TopLeft */
  1728.     NULL,    /* font pointer or NULL for default */
  1729.     "Bd is updated after edit session",    /* pointer to text */
  1730.     &pIText8a    /* next IntuiText structure */
  1731. };
  1732.  
  1733. struct IntuiText __far __aligned pIText6 = {
  1734.     TBLOCKPEN,0,JAM2,    /* front and back text pens, drawmode and fill byte */
  1735.     68,62,    /* XY origin relative to container TopLeft */
  1736.     NULL,    /* font pointer or NULL for default */
  1737.     "Piece to add",    /* pointer to text */
  1738.     &pIText7    /* next IntuiText structure */
  1739. };
  1740.  
  1741. struct IntuiText __far __aligned pIText5 = {
  1742.     TBLOCKPEN,0,JAM2,    /* front and back text pens, drawmode and fill byte */
  1743.     59,24,    /* XY origin relative to container TopLeft */
  1744.     NULL,    /* font pointer or NULL for default */
  1745.     "pa1 for pawn at a1, etc.",    /* pointer to text */
  1746.     &pIText6    /* next IntuiText structure */
  1747. };
  1748.  
  1749. struct IntuiText __far __aligned pIText4 = {
  1750.     TBLOCKPEN,0,JAM2,    /* front and back text pens, drawmode and fill byte */
  1751.     63,14,    /* XY origin relative to container TopLeft */
  1752.     NULL,    /* font pointer or NULL for default */
  1753.     "Enter Pieces in format",    /* pointer to text */
  1754.     &pIText5    /* next IntuiText structure */
  1755. };
  1756.  
  1757. struct NewWindow __far __aligned pNewWindowStructure1 = {
  1758.     170,30,    /* window XY origin relative to TopLeft of screen */
  1759.     300,220,    /* window width and height */
  1760.     0,TBLOCKPEN,    /* detail and block pens */
  1761.     GADGETUP+CLOSEWINDOW,    /* IDCMP flags */
  1762.     WINDOWCLOSE+SIMPLE_REFRESH+ACTIVATE+NOCAREREFRESH,    /* other window flags */
  1763.     &pGadget1,    /* first gadget in gadget list */
  1764.     NULL,    /* custom CHECKMARK imagery */
  1765.     "Edit Board",    /* window title */
  1766.     NULL,    /* custom screen pointer */
  1767.     NULL,    /* custom bitmap */
  1768.     5,5,    /* minimum width and height */
  1769.     0xffff,0xffff,    /* maximum width and height */
  1770.     CUSTOMSCREEN    /* destination screen type */
  1771. };
  1772.  
  1773. void
  1774. SetTimeControl2 (color)
  1775. int color;
  1776. {
  1777.  int tmp;
  1778.  int other;
  1779.  
  1780.   other = color ^ 1;
  1781.   if (TCflag)
  1782.     {
  1783.       TimeControl.moves[color] = TCmoves;
  1784.       TimeControl.clock[color] += (6000L * TCminutes + TCseconds * 100);
  1785.       tmp = (TCminutes*60+TCseconds)/TCmoves;
  1786.       if (color == computer)
  1787.        {
  1788.       SecsPerMove = tmp;
  1789.       if (tmp < 10)
  1790.        {
  1791.         GlobalTgtDepth = 2;
  1792.        }
  1793.       else if (tmp < 180)
  1794.        {
  1795.         GlobalTgtDepth = 3;
  1796.        }
  1797.       else
  1798.        GlobalTgtDepth = 4;
  1799.       }
  1800.       TimeControl.moves[other] = TCmoves;
  1801.       TimeControl.clock[other] += (6000L * TCminutes + TCseconds * 100);
  1802.       tmp = (TCminutes*60+TCseconds)/TCmoves;
  1803.       if (other == computer)
  1804.        {
  1805.       SecsPerMove = tmp;
  1806.       if (tmp < 10)
  1807.        {
  1808.         GlobalTgtDepth = 2;
  1809.        }
  1810.       else if (tmp < 180)
  1811.        {
  1812.         GlobalTgtDepth = 3;
  1813.        }
  1814.       else
  1815.        GlobalTgtDepth = 4;
  1816.       }
  1817.     }
  1818.   else
  1819.     {
  1820.       TimeControl.moves[color] = 0;
  1821.       TimeControl.clock[color] = 0;
  1822.       TimeControl.moves[other] = 0;
  1823.       TimeControl.clock[other] = 0;
  1824.     }
  1825.   flag.onemove = (TCmoves == 1);
  1826.   et = 0;
  1827.   ElapsedTime (1);
  1828. }
  1829.  
  1830. void DoEasy()
  1831. {
  1832.  
  1833.     PlayMode = 0;
  1834.     BobVSprite->X = WIDTH-1-BOBWIDTH;
  1835.     BobVSprite->Y = HEIGHT-1-BOBHEIGHT;
  1836.     LoadBobImage(BLANKDATA);
  1837.     if (SYSTEM_BOBS)
  1838.      {
  1839.       SortGList(rpG);
  1840.       DrawGList(rpG,vP);
  1841.       MakeVPort(GfxBase->ActiView,vP);
  1842.       MrgCop(GfxBase->ActiView);
  1843.       WaitTOF();
  1844.       RethinkDisplay();
  1845.      }
  1846.     NewGame();
  1847. }
  1848.  
  1849. void DoAdvanced()
  1850. {
  1851.  
  1852.     PlayMode = 2;
  1853.     BobVSprite->X = WIDTH-1-BOBWIDTH;
  1854.     BobVSprite->Y = HEIGHT-1-BOBHEIGHT;
  1855.     LoadBobImage(BLANKDATA);
  1856.     if (SYSTEM_BOBS)
  1857.      {
  1858.       SortGList(rpG);
  1859.       DrawGList(rpG,vP);
  1860.      }
  1861.     MakeVPort(GfxBase->ActiView,vP);
  1862.     MrgCop(GfxBase->ActiView);
  1863.     WaitTOF();
  1864.     RethinkDisplay();
  1865.     NewGame();
  1866. }
  1867.  
  1868. void DoIntermediate()
  1869. {
  1870.  
  1871.     PlayMode = 1;
  1872.     BobVSprite->X = WIDTH-1-BOBWIDTH;
  1873.     BobVSprite->Y = HEIGHT-1-BOBHEIGHT;
  1874.     LoadBobImage(BLANKDATA);
  1875.     if (SYSTEM_BOBS)
  1876.      {
  1877.       SortGList(rpG);
  1878.       DrawGList(rpG,vP);
  1879.      }
  1880.     MakeVPort(GfxBase->ActiView,vP);
  1881.     MrgCop(GfxBase->ActiView);
  1882.     WaitTOF();
  1883.     RethinkDisplay();
  1884.     NewGame();
  1885. }
  1886.  
  1887.  
  1888. void
  1889. gsrand (unsigned int seed)
  1890. {
  1891.   next = seed;
  1892. }
  1893.  
  1894.  
  1895. void calc_pgm_rating()
  1896. {
  1897.  /* 34 secs on an RS/6000 which is about 2338, so to rate itself
  1898.     rating = 2338 - 75*(log2(time) - log2(34)) */
  1899.  
  1900.  int st;
  1901.  unsigned int secs;
  1902.  int rating;
  1903.  int tmpbk,Old,oldtc;
  1904.  int OldPM;
  1905.  char tstr[32],tstr2[32];
  1906.  
  1907.  OldPM = PlayMode;
  1908.  PlayMode = 2;
  1909.  tmpbk = Book;
  1910.  oldtc = TCflag;
  1911.  Old = MaxSearchDepth;
  1912.  NewGame ();
  1913.  UpdateDisplay (0, 0, 1, 0);
  1914.  MaxSearchDepth = 6;
  1915.  Book = 0;
  1916.  TCflag = 0;
  1917.  computer = computer ^ 1;
  1918.  opponent = opponent ^ 1;
  1919.  xwndw = (computer == white) ? WXWNDW : BXWNDW;
  1920.  flag.force = false;
  1921.  Sdepth = 0;
  1922.  ShowMessage("Calculating.");
  1923.  ShowMessage("Please wait.");
  1924.  SetPointer(wG,myPointer,PTRHEIGHT,0x10L,0L,0L);
  1925.  st = time(0L);
  1926.  SelectMove (computer, 1);
  1927.  secs = st = time(0L) - st;
  1928.  ClearPointer(wG);
  1929.  if (st<4)
  1930.   st = 4;
  1931.  st = (st - 2)/6;
  1932.  if (st > 200)
  1933.   {
  1934.    strcpy(tstr,"too slow Cannot rate");
  1935.   }
  1936.  else
  1937.   {
  1938.    if (st < 4)
  1939.     st = 4;
  1940. #ifdef PL_60
  1941.    rating = 2350 - (((75*log_e[st]) - (75*LOGE_34))/LN2);
  1942. #else /* patch level 61 */
  1943.    rating = 2350 - (((75*log_e[st]) - (75*LOGE_16))/LN2);
  1944. #endif
  1945. #ifndef _M68040 /* small mem model */
  1946. #ifdef TINYCHESS
  1947.    rating -= 41;
  1948. #else
  1949.    rating -= 21;
  1950. #endif
  1951. #endif
  1952.    rating -= 40;
  1953.    sprintf(tstr,"USCF %04d",rating);
  1954.   }
  1955.  Book = tmpbk;
  1956.  MaxSearchDepth = Old;
  1957.  TCflag = oldtc;
  1958.  PlayMode = OldPM;
  1959.  NewGame ();
  1960.  UpdateDisplay (0, 0, 1, 0);
  1961.  sprintf(tstr2," %d secs",secs);
  1962.  ShowMessage(tstr2);
  1963.  ShowMessage(tstr);
  1964. }
  1965.  
  1966. int DoResign()
  1967. {
  1968.  struct EasyStruct __aligned resignES = {
  1969.     sizeof (struct EasyStruct),
  1970.     0,
  1971.     "Resignation Alert",
  1972.     "Accept UChess's Resignation",
  1973.     "Yes|No",
  1974.   };
  1975.  
  1976.  ULONG __aligned iflags=0L;
  1977.  UBYTE    __aligned volname[4]={0,0,0,0};
  1978.  
  1979.  Delay(30L);
  1980.  DisplayBeep(0L);
  1981.  ResignOffered = -1;
  1982. /* return 0 if no resign accepted, yes if accepted */
  1983.  return(EasyRequest( wG, &resignES, &iflags, volname ));
  1984. }
  1985.  
  1986.  
  1987. void GetEditText(s,color)
  1988. char *s;
  1989. int *color;
  1990. { /* gets the edit string from the user */
  1991.   /* returns # for clr bd, c for change colors and pa1 to put a pawn at a1*/
  1992.   /* YOU MUST RETURN THE STRING IN ALL LOWER CASE! */
  1993.  
  1994.   int dun;
  1995.   long code,class;
  1996.   int i;
  1997.   APTR object;
  1998.   struct IntuiMessage *message;
  1999.  
  2000.   dun = 0;
  2001.   s[0] = 0;
  2002.   pppSIBuff[0] = '\0';
  2003.   ActivateGadget(&pGadget1,wGEdit,NULL);
  2004.   do {
  2005.   WaitPort(wGEdit->UserPort);
  2006.   while(message = (struct IntuiMessage *)GetMsg(wGEdit->UserPort))
  2007.   {
  2008.    code = message->Code;
  2009.    object = message->IAddress;
  2010.    class = message->Class;
  2011.    ReplyMsg((struct Message *)message);
  2012.    if (class == CLOSEWINDOW)
  2013.     {
  2014.      strcpy(s,".");
  2015.      dun = 1;
  2016.     }
  2017.    else if (class == GADGETUP)
  2018.     { /* text */
  2019.      if (object == (APTR)&pGadget1)
  2020.       {
  2021.        if (pppSIBuff[0])
  2022.         {
  2023.          dun = 1;
  2024.          strcpy(s,pppSIBuff);
  2025.          for(i=0;i<4;i++)
  2026.           s[i] = tolower(s[i]);
  2027.         }
  2028.       }
  2029.      else if (object == (APTR)&pGadget2)
  2030.       {
  2031.        dun = 1;
  2032.        strcpy(s,"#");
  2033.       }
  2034.      else if (object == (APTR)&pGadget3)
  2035.       { /* white/black */
  2036.        if (*color == white)
  2037.         *color = black;
  2038.        else
  2039.         *color = white;
  2040.        SetDrMd(wGEdit->RPort,JAM1);
  2041.        SetAPen(wGEdit->RPort,0L);
  2042.        RectFill(wGEdit->RPort,107,124,167,145);
  2043.        if (*color == white)
  2044.         PrintIText(wGEdit->RPort,&pIText2,0L,0L); /* white label */
  2045.        else
  2046.         PrintIText(wGEdit->RPort,&pIText2a,0L,0L); /* white label */
  2047.       }
  2048.      else if (object == (APTR)&pGadget4)
  2049.       { /* done */
  2050.        strcpy(s,".");
  2051.        dun = 1;
  2052.       }
  2053.     }
  2054.   }
  2055.  } while (!dun);
  2056.  DisplayBeep(0L);
  2057. }
  2058.  
  2059. void CloseAmigaEditWindow()
  2060. {
  2061.  struct IntuiMessage *message;
  2062.  
  2063.   while(message = (struct IntuiMessage *)GetMsg(wGEdit->UserPort))
  2064.   {
  2065.    ReplyMsg((struct Message *)message);
  2066.   }
  2067.  CloseWindow(wGEdit);
  2068. // if (DEPTH >= 6)
  2069. //  {
  2070. //   SetRGB32(vP,1,tmppal[0],tmppal[1],tmppal[2]);
  2071. //  }
  2072. // else
  2073. //  {
  2074. //   SetRGB4(vP,1,((tmppal[0]>>8)&0xf),((tmppal[0]>>4)&0xf),((tmppal[0])&0xf));
  2075. //  }
  2076. }
  2077.  
  2078.  
  2079. int OpenAmigaEditWindow() /* opens a window for edit board */
  2080.  {
  2081.   if (!(wGEdit = OpenWindow(&pNewWindowStructure1)))
  2082.    {
  2083.     DisplayBeep(0L);
  2084.     return(0);
  2085.    }
  2086. // if (DEPTH >= 6)
  2087. //  {
  2088. //   tmppal[0] = BigColorPalette[4];
  2089. //   tmppal[1] = BigColorPalette[5];
  2090. //   tmppal[2] = BigColorPalette[6];
  2091. //   SetRGB32(vP,1,0xaaaaaaaa,0xaaaaaaaa,0xaaaaaaaa);
  2092. //  }
  2093. // else
  2094.  // {
  2095.  //  tmppal[0] = myPalette[1];
  2096. //   SetRGB4(vP,1,0xa,0xa,0xa);
  2097. //  }
  2098.   pppSIBuff[0] = 0;
  2099.   pppSIBuff[3] = 0;
  2100.   PrintIText(wGEdit->RPort,&pIText4,0L,0L);
  2101.   PrintIText(wGEdit->RPort,&pIText2,0L,0L); /* white label */
  2102.   return(1);
  2103.  }
  2104.  
  2105.  
  2106. void EnableMoveNow()
  2107. {
  2108.  if (MenuStripSet)
  2109.   {
  2110.    MoveNowOK = 1;
  2111.    OnMenu(wG,MOVENOWMENUNUM); 
  2112.   }
  2113. }
  2114.  
  2115. void DisableMoveNow()
  2116. {
  2117.  if (MenuStripSet)
  2118.   {
  2119.    MoveNowOK = 0;
  2120.    OffMenu(wG,MOVENOWMENUNUM); 
  2121.   }
  2122. }
  2123.  
  2124. int GetFileName(char *s)
  2125. {
  2126.  int tmp;
  2127.  struct FileRequester *myFileReq;
  2128.  struct  TagItem  Tags[2] = {
  2129.  {ASLFR_Window,0L},
  2130.  {0,0}
  2131.  };
  2132.  
  2133.  Tags[0].ti_Data = (ULONG)wG;
  2134.  myFileReq = AllocAslRequest(ASL_FileRequest,Tags);
  2135.  if (myFileReq)
  2136.   {
  2137.    tmp = AslRequest(myFileReq,Tags);
  2138.    if (!tmp)
  2139.     {
  2140.      FreeAslRequest(myFileReq);
  2141.      return(0);
  2142.     }
  2143.    strcpy(s,myFileReq->fr_Drawer);
  2144.    if (s[0])
  2145.     {
  2146.      if ((s[strlen(s)-1] != ':')&&(s[strlen(s)-1] != '/'))
  2147.       {
  2148.        strcat(s,"/");
  2149.       }
  2150.     }
  2151.    strcat(s,myFileReq->fr_File);
  2152.    FreeAslRequest(myFileReq);
  2153.    return(0xff);
  2154.   }
  2155.  else
  2156.   return(0);
  2157. }
  2158.  
  2159. int GetScreenMode()
  2160. {
  2161.  int tmp;
  2162.  struct ScreenModeRequester *myScreenReq;
  2163.  struct TagItem  Tags[4] = {
  2164.  {ASLSM_InitialDisplayID,HIRES|LACE|DEFAULT_MONITOR_ID},
  2165.  {ASLSM_InitialAutoScroll,FALSE},
  2166.  {0,0}
  2167.  };
  2168.  
  2169.  myScreenReq = AllocAslRequest(ASL_ScreenModeRequest,0L);
  2170.  if (myScreenReq)
  2171.   {
  2172.    tmp = AslRequest(myScreenReq,Tags);
  2173.    if (!tmp)
  2174.     {
  2175.      FreeAslRequest(myScreenReq);
  2176.      return(0);
  2177.     }
  2178.    RTG_ModeID = myScreenReq->sm_DisplayID;
  2179.    FreeAslRequest(myScreenReq);
  2180.    return(0xff);
  2181.   }
  2182.  else
  2183.   return(0);
  2184. }
  2185.  
  2186. void
  2187. UpdateClocks (void)
  2188. {
  2189.   char tempstr[16];
  2190.   long ycoord;
  2191.   INTSIZE ref_min,ref_sec;
  2192.   ULONG max_time;
  2193.   INTSIZE m, s;
  2194.  
  2195.   m = (INTSIZE) (et / 6000);
  2196.   s = (INTSIZE) (et - 6000 * (long) m) / 100;
  2197.   if (TCflag)
  2198.     {
  2199.       m = (INTSIZE) ((TimeControl.clock[player] - et) / 6000);
  2200.       s = (INTSIZE) ((TimeControl.clock[player] - et - 6000 * (long) m) / 100);
  2201.     }
  2202.   if (m < 0)
  2203.     m = 0;
  2204.   if (s < 0)
  2205.     s = 0;
  2206.   if (player == computer)
  2207.    {
  2208.     ref_min = cmptr_min;
  2209.     ref_sec = cmptr_sec;
  2210.     ycoord = TIMEYCOORD1;
  2211.    }
  2212.   else
  2213.    {
  2214.     ref_min = hum_min;
  2215.     ref_sec = hum_sec;
  2216.     ycoord = TIMEYCOORD2;
  2217.    }
  2218.   if ((ref_min != m)||(ref_sec != s))
  2219.    {
  2220.     sprintf(tempstr,"%d:%02d     ",m,s);
  2221.     Move(rpG,540,ycoord);
  2222.     mySetABPenDrMd(rpG,BACKGNDTEXTCOLOR,bpen,JAM1);
  2223.     RectFill(rpG,540,ycoord-6,621,ycoord+5);
  2224.     mySetABPenDrMd(rpG,BLACK,bpen,JAM1);
  2225.     Move(rpG,540,ycoord);
  2226.     Text(rpG,tempstr,strlen(tempstr));
  2227.    }
  2228.   if (player == computer)
  2229.    {
  2230.     cmptr_min = m;
  2231.     cmptr_sec = s;
  2232.     if (TCflag)
  2233.      {
  2234.       max_time = s + m*60;
  2235.       if ((TimeControl.moves[computer] < ((TCmoves/2)-2))&&(Sdepth > GlobalTgtDepth)&&
  2236.           (global_tmp_score >= (previous_score - 55))&&(ResponseTime < 9999998)&&
  2237.           (max_time<(((TimeControl.moves[computer]-1)*SecsPerMove)>>1)))
  2238.        {//have little time available on 2nd half of game
  2239.         flag.back = true;
  2240.        }
  2241.       if ((!m)&&(s <= 1)&&(Sdepth > MINDEPTH))
  2242.        {
  2243.         flag.back = true;
  2244.        }
  2245.       if ((Sdepth > MINDEPTH)&&(!m)&&
  2246.           (s<((TimeControl.moves[player]-1)*5)))
  2247.        { // less than 1 min left on clock, less than 5 secs/move!
  2248.         flag.back = true;
  2249.        }
  2250.     }
  2251.   /*printf("prev score = %d  global_tmp_score = %d\n",previous_score,global_tmp_score);*/
  2252.     if (Sdepth > (GlobalTgtDepth+1))
  2253.      max_time = (OrigResponse<<1) + ExtraTime + 151;
  2254.     else
  2255.      max_time = ((OrigResponse<<1) + ExtraTime + OrigResponse);
  2256.     if ((TCflag) && (!trying_again) && (ResponseTime < 9999998) && (Sdepth > MINDEPTH)
  2257.         && ((et) >= max_time))
  2258.      {
  2259.       if (global_tmp_score >= (previous_score - 75))
  2260.         {
  2261.          flag.back = true;
  2262.         }
  2263.      } 
  2264.    }
  2265.   else // human player
  2266.    {
  2267.     hum_min = m;
  2268.     hum_sec = s;
  2269.    }
  2270. }
  2271.  
  2272.  
  2273. char DisplayPromoteRequestor(void);
  2274.  
  2275. char DisplayPromoteRequestor()
  2276. {
  2277. // ULONG tmp[4];
  2278.  int dun;
  2279.  struct IntuiMessage __aligned *message;
  2280.  struct Window __aligned *wG3;
  2281.  UWORD __aligned code;
  2282.  ULONG __aligned class;
  2283.  APTR object;
  2284.  char retchar='q';
  2285.  
  2286. // if (DEPTH >= 6)
  2287. //  {
  2288. //   tmp[0] = BigColorPalette[4];
  2289. //   tmp[1] = BigColorPalette[5];
  2290. //   tmp[2] = BigColorPalette[6];
  2291. //   SetRGB32(vP,1,0xaaaaaaaa,0xaaaaaaaa,0xaaaaaaaa);
  2292. // }
  2293. // else
  2294. //  {
  2295. //   tmp[0] = myPalette[1];
  2296. //   SetRGB4(vP,1,0xa,0xa,0xa);
  2297. //  }
  2298.  if (!(wG3 = OpenWindow(&NewWindowStructure6)))
  2299.  {
  2300.   DisplayBeep(0L);
  2301.   return('q');
  2302.  }
  2303.  PrintIText(wG3->RPort,&aIText5,0L,0L);
  2304.  dun = 0;
  2305.  do {
  2306.  WaitPort(wG3->UserPort);
  2307.  while(message = (struct IntuiMessage *)GetMsg(wG3->UserPort))
  2308.   {
  2309.    code = message->Code;
  2310.    object = message->IAddress;
  2311.    class = message->Class;
  2312.    ReplyMsg((struct Message *)message);
  2313.    dun = 1;
  2314.    if (object == (APTR)&aGadget1)
  2315.       {
  2316.        retchar = 'q';
  2317.       }
  2318.     else if (object == (APTR)&aGadget2)
  2319.       {
  2320.        retchar = 'r';
  2321.       }
  2322.     else if (object == (APTR)&aGadget3)
  2323.       {
  2324.        retchar = 'b';
  2325.       }
  2326.     else if (object == (APTR)&aGadget4)
  2327.       {
  2328.        retchar = 'n';
  2329.       }
  2330.   }
  2331.  } while (!dun);
  2332.  CloseWindow(wG3);
  2333. // if (DEPTH >= 6)
  2334. //  {
  2335. //   SetRGB32(vP,1,tmp[0],tmp[1],tmp[2]);
  2336. //  }
  2337. // else
  2338.  // {
  2339.  //  SetRGB4(vP,1,((tmp[0]>>8)&0xf),((tmp[0]>>4)&0xf),((tmp[0])&0xf));
  2340. //  }
  2341.  return(retchar);
  2342. }
  2343.  
  2344. void tFreeBitMap(struct BitMap *);
  2345. void sFreeBitMap(struct BitMap *);
  2346. struct BitMap *tAllocBitMap(int,int,int,int,struct BitMap *);
  2347. struct BitMap *sAllocBitMap(int,int,int,int,struct BitMap *);
  2348.  
  2349. struct BitMap *tAllocBitMap(wid,ht,depth,flags,friend)
  2350. int wid,ht,depth,flags;
  2351. struct BitMap *friend;
  2352. {
  2353.  int i;
  2354.  unsigned long tt;
  2355.  LONG image_data;
  2356.  ULONG planes;
  2357.  struct BitMap *tmp;
  2358.  
  2359.  if (gfxversion < 39)
  2360.   {
  2361.    planes = RASSIZE(wid,ht);
  2362.    if (!(tmp = AllocMem(sizeof (struct BitMap),MEMF_CLEAR)))
  2363.     {
  2364.      return(0);
  2365.     }
  2366.    InitBitMap(tmp,depth,wid,ht);
  2367.    tt = planes*depth;
  2368.    if (!(tmp->Planes[0] = AllocMem(tt,MEMF_CHIP|MEMF_CLEAR)))
  2369.     {
  2370.      FreeMem(tmp,sizeof(struct BitMap));
  2371.      return(0);
  2372.     }
  2373.    image_data = (LONG)tmp->Planes[0];
  2374.    for(i=1;i<depth;i++)
  2375.     {
  2376.      tmp->Planes[i] = (PLANEPTR) (image_data + i * planes);
  2377.     }
  2378.   }
  2379.  else
  2380.   {
  2381.    tmp = AllocBitMap(wid,ht,depth,flags,friend);
  2382.   }
  2383.  return(tmp);
  2384. }
  2385.  
  2386. struct BitMap *sAllocBitMap(wid,ht,depth,flags,friend)
  2387. int wid,ht,depth,flags;
  2388. struct BitMap *friend;
  2389. {
  2390.  int i;
  2391.  unsigned long tt;
  2392.  ULONG image_data;
  2393.  ULONG planes;
  2394.  struct BitMap *tmp;
  2395.  
  2396.  
  2397.  if (!(tmp = AllocMem(sizeof (struct BitMap),MEMF_CLEAR)))
  2398.   {
  2399.    return(0);
  2400.   }
  2401.  InitBitMap(tmp,8,640,480);
  2402.  planes = RASSIZE(640,480);
  2403.  tmp->BytesPerRow = 640;
  2404.  tmp->Flags = 0x0;
  2405.  tmp->Rows = 480;
  2406.  tmp->Depth = 8;
  2407.  tmp->pad = 32860;
  2408.  tt = planes*8;
  2409.  if (!(tmp->Planes[0] = AllocMem(tt,MEMF_CHIP|MEMF_CLEAR)))
  2410.   {
  2411.    FreeMem(tmp,sizeof(struct BitMap));
  2412.    return(0);
  2413.   }
  2414.  image_data = (ULONG)tmp->Planes[0];
  2415.  planes = 0x50;
  2416.  for(i=1;i<depth;i++)
  2417.   {
  2418.    tmp->Planes[i] = (PLANEPTR) (image_data + i * planes);
  2419.   }
  2420.  return(tmp);
  2421. }
  2422.  
  2423. void tFreeBitMap(bmap)
  2424. struct BitMap *bmap;
  2425. {
  2426.  ULONG numbytes;
  2427.  
  2428.  if (gfxversion < 39)
  2429.   {
  2430.    numbytes = bmap->Rows*bmap->BytesPerRow*bmap->Depth;
  2431.    FreeMem(bmap->Planes[0],numbytes);
  2432.    FreeMem(bmap,sizeof(struct BitMap));
  2433.   }
  2434.  else
  2435.   {
  2436.    FreeBitMap(bmap);
  2437.   }
  2438. }
  2439.  
  2440. void sFreeBitMap(bmap)
  2441. struct BitMap *bmap;
  2442. {
  2443.  ULONG numbytes,planes;
  2444.  
  2445.   planes = RASSIZE(640,480);
  2446.   numbytes = planes*8;
  2447.   FreeMem(bmap->Planes[0],numbytes);
  2448.   FreeMem(bmap,sizeof(struct BitMap));
  2449. }
  2450.  
  2451.  
  2452. void HandleEvent(object)
  2453. APTR object;
  2454. {
  2455.  UWORD nextcode;
  2456.  struct MenuItem *myMenuItem;
  2457.  
  2458.  do {
  2459.   if (object == (APTR)&MenuItem12) { DoAbout(); }
  2460.   if (object == (APTR)&MenuItem13) { LoadAGame(); }
  2461.   if (object == (APTR)&MenuItem14) { SaveAGame(); }
  2462.   if (object == (APTR)&MenuItem14a) { ListAGame();  }
  2463.   if (object == (APTR)&MenuItem15) { DoQuit();return; }
  2464.   if (object == (APTR)&MenuItem9) { Go2D(); }
  2465.   if (object == (APTR)&MenuItem10) { EditBoard(); }
  2466.   if (object == (APTR)&MenuItem11) { DoReverse(); }
  2467.   if (object == (APTR)&MenuItem4) { DoSwap();  }
  2468.   if (object == (APTR)&MenuItem5) { DoAutoPlay(); }
  2469.   if (object == (APTR)&MenuItem6) { MoveNow();  }
  2470.   if (object == (APTR)&MenuItem7) { TakeBack();  }
  2471.   if (object == (APTR)&MenuItem8) { DoThinking();  }
  2472.   if (object == (APTR)&MenuItem8a) { DoShwThnk();  }
  2473.   if (object == (APTR)&MenuItem8aa) { DoSuper(); }
  2474.   if (object == (APTR)&MenuItem8ab) { DoBookToggle(); }
  2475.   if (object == (APTR)&MenuItem8ee) { DoAdvanced();  }
  2476.   if (object == (APTR)&MenuItem8dd) { DoIntermediate();  }
  2477.   if (object == (APTR)&MenuItem8cc) { DoEasy(); }
  2478.   if (object == (APTR)&MenuItem1) { DoHint(); }
  2479.   if (object == (APTR)&MenuItem2) { DoTest();  }
  2480.   if (object == (APTR)&MenuItem3) { SetTime(); }
  2481.   if (object == (APTR)&MenuItem3x) { calc_pgm_rating(); }
  2482.   if (object == (APTR)&MenuItem3r) { ChangeSearchDepth();}
  2483.   if (object == (APTR)&MenuItem28) 
  2484.    { 
  2485.     BobVSprite->X = WIDTH-1-BOBWIDTH;
  2486.     BobVSprite->Y = HEIGHT-1-BOBHEIGHT;
  2487.     LoadBobImage(BLANKDATA);
  2488.     if (SYSTEM_BOBS)
  2489.      {
  2490.       SortGList(rpG);
  2491.       DrawGList(rpG,vP);
  2492.      }
  2493.     MakeVPort(GfxBase->ActiView,vP);
  2494.     MrgCop(GfxBase->ActiView);
  2495.     WaitTOF();
  2496.     RethinkDisplay();
  2497.     NewGame();
  2498.    }
  2499.   myMenuItem = (struct MenuItem *)object;
  2500.   nextcode = myMenuItem->NextSelect;
  2501.   if (nextcode != MENUNULL)
  2502.    {
  2503.     object = (APTR)ItemAddress(&MenuList1,nextcode);
  2504.    }
  2505.   } while (nextcode != MENUNULL);
  2506. }
  2507.  
  2508.  
  2509. void DoAbout()
  2510. {
  2511.  int done=0;
  2512.  struct IntuiMessage __aligned *message;
  2513.  struct Window __aligned *wG3;
  2514.  ULONG class,code;
  2515.  
  2516.  if (!(wG3 = OpenWindow(&NewWindowStructure2)))
  2517.  {
  2518.   DisplayBeep(0L);
  2519.   return;
  2520.  }
  2521.  PrintIText(wG3->RPort,&IText17,0L,0L);
  2522.  do {
  2523.   WaitPort(wG3->UserPort);
  2524.   while(message = (struct IntuiMessage *)GetMsg(wG3->UserPort))
  2525.    {
  2526.     class = message->Class;
  2527.     code = message->Code;
  2528.     ReplyMsg((struct Message *)message);
  2529.     if (class == GADGETUP)
  2530.      done = 1;
  2531.     else if (class == VANILLAKEY)
  2532.      {
  2533.       if ((code == 13)||(code == 10))
  2534.        done = 1;
  2535.      }
  2536.    }
  2537.  } while (!done);
  2538.  CloseWindow(wG3);
  2539. }
  2540.  
  2541.  
  2542. void LoadAGame(void)
  2543. {
  2544.  GetGame();
  2545. }
  2546.  
  2547. void SaveAGame(void)
  2548. {
  2549.  SaveGame();
  2550. }
  2551.  
  2552. void ListAGame(void)
  2553. {
  2554.  ListGame(0xff);
  2555. }
  2556.  
  2557. void DoQuit(void)
  2558. {
  2559.  flag.quit = true;
  2560. }
  2561.  
  2562. void Go2D(void)
  2563. {
  2564. }
  2565.  
  2566. void DoReverse(void)
  2567. {
  2568. }
  2569.  
  2570. void DoSwap(void)
  2571. {
  2572.  doswap = 1;
  2573. }
  2574.  
  2575. void DoAutoPlay(void)
  2576. {
  2577.  hint = 0;
  2578.  SetPointer(wG,myPointer,PTRHEIGHT,0x10L,0L,0L);
  2579.  doauto = 1;
  2580. }
  2581.  
  2582. void MoveNow(void)
  2583. {
  2584. }
  2585.  
  2586. void TakeBack(void)
  2587. {
  2588.  char mvnstr[16];
  2589.  int currpiece;
  2590.  long tmp1,tmp2;
  2591.  int r,c,l;
  2592.  
  2593.  
  2594.  doundo = 1;
  2595.  hint = 0;
  2596.  if (GameCnt <= 0)
  2597.   return;
  2598.  for (r = 7; r >= 0; r--)
  2599.   {
  2600.    for (c = 0; c <= 7; c++)
  2601.     {
  2602.       l = ((flag.reverse) ? locn (7 - r, 7 - c) : locn (r, c));
  2603.       if (color[l] == neutral)
  2604.     oldboard[r][c] = ' ';
  2605.       else if (color[l] == white)
  2606.     oldboard[r][c] = qxx[board[l]];
  2607.       else
  2608.     oldboard[r][c] = pxx[board[l]];
  2609.     }
  2610.   }
  2611.  BobVSprite->X = WIDTH-1-BOBWIDTH;
  2612.  BobVSprite->Y = HEIGHT-1-BOBHEIGHT;
  2613.  LoadBobImage(BLANKDATA);
  2614.  if (SYSTEM_BOBS)
  2615.   {
  2616.    SortGList(rpG);
  2617.    DrawGList(rpG,vP);
  2618.   }
  2619.  Undo();
  2620.  for (r = 7; r >= 0; r--)
  2621.     {
  2622.      for (c = 0; c <= 7; c++)
  2623.       {
  2624.         l = ((flag.reverse) ? locn (7 - r, 7 - c) : locn (r, c));
  2625.         if ((color[l] == neutral)&&(oldboard[r][c] != ' '))
  2626.          {
  2627.       tmp1 = r & 1L;
  2628.           tmp2 = c & 1L;
  2629.           if (((!tmp1) && (!tmp2)) || ((tmp1)&&(tmp2)))
  2630.            {
  2631.             BltBitMap(BlackBitMap,0,0,myBitMap,ColArray[c],
  2632.             RowArray[r],SQUAREWIDTH,SQUAREHEIGHT,
  2633.             0xc0L,0xffL,0L);
  2634.            }
  2635.           else
  2636.            {
  2637.             BltBitMap(WhiteBitMap,0,0,myBitMap,ColArray[c],
  2638.             RowArray[r],SQUAREWIDTH,SQUAREHEIGHT,
  2639.             0xc0L,0xffL,0L);
  2640.            }
  2641.          }
  2642.         else
  2643.          {
  2644.           if (color[l] == white)
  2645.        currpiece = qxx[board[l]];
  2646.           else
  2647.        currpiece = pxx[board[l]];
  2648.           if (currpiece != oldboard[r][c])
  2649.            {
  2650.         tmp1 = r & 1L;
  2651.             tmp2 = c & 1L;
  2652.             if (((!tmp1) && (!tmp2)) || ((tmp1)&&(tmp2)))
  2653.              {
  2654.               BltBitMap(BlackBitMap,0,0,myBitMap,ColArray[c],
  2655.                 RowArray[r],SQUAREWIDTH,SQUAREHEIGHT,
  2656.                 0xc0L,0xffL,0L);
  2657.              }
  2658.             else
  2659.              {
  2660.               BltBitMap(WhiteBitMap,0,0,myBitMap,ColArray[c],
  2661.                 RowArray[r],SQUAREWIDTH,SQUAREHEIGHT,
  2662.                 0xc0L,0xffL,0L);
  2663.              }
  2664.         LoadBobImage(currpiece);
  2665.             ClipBlitTrans (
  2666.         &(BobTransImage->ti_RP),    /* Source RastPort */
  2667.              0, 0,        /* Source LeftEdge, TopEdge */
  2668.              rpG,        /* Destination RastPort */
  2669.              ColArray[c],RowArray[r],/* Destination LeftEdge, TopEdge */
  2670.              BobTransImage->ti_IM->Width,    /* Width of Image */
  2671.              BobTransImage->ti_IM->Height,/* Height of Image */
  2672.              BobTransImage->ti_sRP);    /* Shadow RastPort */
  2673.             BobVSprite->X = WIDTH-1-BOBWIDTH;
  2674.             BobVSprite->Y = HEIGHT-1-BOBHEIGHT;
  2675.             LoadBobImage(BLANKDATA);
  2676.             if (SYSTEM_BOBS)
  2677.              {
  2678.               SortGList(rpG);
  2679.               DrawGList(rpG,vP);
  2680.              }
  2681.            }
  2682.          }
  2683.       }
  2684.     }
  2685.  BobVSprite->X = WIDTH-1-BOBWIDTH;
  2686.  BobVSprite->Y = HEIGHT-1-BOBHEIGHT;
  2687.  LoadBobImage(BLANKDATA);
  2688.  if (SYSTEM_BOBS)
  2689.   {
  2690.    SortGList(rpG);
  2691.    DrawGList(rpG,vP);
  2692.   }
  2693.  mySetABPenDrMd(rpG,BACKGNDTEXTCOLOR,bpen,JAM1);
  2694.  RectFill(rpG,520,USERBOX,621,USERBOX+30);
  2695.  Move(rpG,520,USERBOX+6);
  2696.  if (computer != black)
  2697.   sprintf(mvnstr,"%d: ",(GameCnt+1)>>1);
  2698.  else
  2699.   sprintf(mvnstr,"%d: ",(GameCnt+2)>>1);
  2700.  mySetABPenDrMd(rpG,BLACK,bpen,JAM1);
  2701.  Text(rpG,mvnstr,strlen(mvnstr));
  2702. }
  2703.  
  2704. void DoThinking(void)
  2705. {
  2706.  flag.easy = !flag.easy;
  2707. }
  2708.  
  2709. void DoShwThnk(void)
  2710. {
  2711.  flag.post = !flag.post;
  2712. }
  2713.  
  2714. void DoSuper(void)
  2715. {
  2716.  SupervisorMode = !SupervisorMode;
  2717. }
  2718.  
  2719. void DoBookToggle(void)
  2720. {
  2721.     Book = Book ? 0 : BOOKFAIL;
  2722.         bookflag = Book;
  2723. }
  2724.  
  2725. void DoHint(void)
  2726. {
  2727.  GiveHint();
  2728. }
  2729.  
  2730. void DoTest(void)
  2731. {
  2732.  teston = 1;
  2733. }
  2734.  
  2735. int SetAmigaDepth()
  2736. {
  2737.  int dun;
  2738.  struct IntuiMessage __aligned *message;
  2739.  struct Window __aligned *wG3;
  2740.  UWORD __aligned code;
  2741.  ULONG __aligned class;
  2742.  APTR object;
  2743. // ULONG tmp[3];
  2744.  
  2745. // if (DEPTH >= 6)
  2746. //  {
  2747. //   tmp[0] = BigColorPalette[4];
  2748. //   tmp[1] = BigColorPalette[5];
  2749. //   tmp[2] = BigColorPalette[6];
  2750. //   SetRGB32(vP,1,0xaaaaaaaa,0xaaaaaaaa,0xaaaaaaaa);
  2751. //  }
  2752. // else
  2753. //  {
  2754. //   tmp[0] = myPalette[1];
  2755. //   SetRGB4(vP,1,0xa,0xa,0xa);
  2756. //  }
  2757.  sprintf(Gadget6SIBuff,"%d",MaxSearchDepth);
  2758.  NewWindowStructure5.FirstGadget = &Gadget6b;
  2759.  if (!(wG3 = OpenWindow(&NewWindowStructure5)))
  2760.  {
  2761.   DisplayBeep(0L);
  2762.   return(0);
  2763.  }
  2764.  Move(wG3->RPort,66,39);
  2765.  Text(wG3->RPort,"Depth",5);
  2766.  ActivateGadget(&Gadget6,wG3,NULL);
  2767.  dun = 0;
  2768.  do {
  2769.  WaitPort(wG3->UserPort);
  2770.  while(message = (struct IntuiMessage *)GetMsg(wG3->UserPort))
  2771.   {
  2772.    code = message->Code;
  2773.    object = message->IAddress;
  2774.    class = message->Class;
  2775.    ReplyMsg((struct Message *)message);
  2776. #ifdef SELECTIVEBB
  2777.    if (object != (APTR)&Gadget6b)
  2778.       {
  2779.        dun = 1;
  2780.       }
  2781. #else
  2782.    dun = 1;
  2783. #endif
  2784.   }
  2785.  } while (!dun);
  2786.  CloseWindow(wG3);
  2787. // if (DEPTH >= 6)
  2788. //  {
  2789. //   SetRGB32(vP,1,tmp[0],tmp[1],tmp[2]);
  2790. //  }
  2791. // else
  2792. //  {
  2793. //   SetRGB4(vP,1,((tmp[0]>>8)&0xf),((tmp[0]>>4)&0xf),((tmp[0])&0xf));
  2794. //  }
  2795.  dun = atoi(Gadget6SIBuff);
  2796.  if (dun > (MAXDEPTH-1))
  2797.   dun = MAXDEPTH -1;
  2798.  if (dun < MINDEPTH)
  2799.   dun = MINDEPTH;
  2800.  NewWindowStructure5.FirstGadget = &Gadget6;
  2801.  return(dun);
  2802. }
  2803.  
  2804. void SetTime(void)
  2805. {
  2806.  int dun;
  2807.  char str[128];
  2808.  struct IntuiMessage __aligned *message;
  2809.  struct Window __aligned *wG3;
  2810.  UWORD __aligned code;
  2811.  ULONG __aligned class;
  2812.  APTR object;
  2813. // ULONG tmp[3];
  2814.  struct Gadget *tg;
  2815.  
  2816. // if (DEPTH >= 6)
  2817. //  {
  2818. //   tmp[0] = BigColorPalette[4];
  2819. //   tmp[1] = BigColorPalette[5];
  2820. //   tmp[2] = BigColorPalette[6];
  2821. //   SetRGB32(vP,1,0xaaaaaaaa,0xaaaaaaaa,0xaaaaaaaa);
  2822. //  }
  2823.  //else
  2824. //  {
  2825. //   tmp[0] = myPalette[1];
  2826. //   SetRGB4(vP,1,0xa,0xa,0xa);
  2827. //  }
  2828.  sprintf(Gadget6SIBuff,"%d",TCmoves);
  2829.  sprintf(Gadget8SIBuff,"%d",(TCminutes));
  2830.  if (!(wG3 = OpenWindow(&NewWindowStructure5)))
  2831.  {
  2832.   DisplayBeep(0L);
  2833.   return;
  2834.  }
  2835.  PrintIText(wG3->RPort,&IText46,0L,0L);
  2836.  ActivateGadget(&Gadget6,wG3,NULL);
  2837.  dun = 0;
  2838.  do {
  2839.  WaitPort(wG3->UserPort);
  2840.  while(message = (struct IntuiMessage *)GetMsg(wG3->UserPort))
  2841.   {
  2842.    code = message->Code;
  2843.    object = message->IAddress;
  2844.    class = message->Class;
  2845.    ReplyMsg((struct Message *)message);
  2846.    if (object != (APTR)&Gadget9)
  2847.       {
  2848.        if (object == (APTR)&Gadget6)
  2849.         {
  2850.          tg = &Gadget8;
  2851.          ActivateGadget(tg,wG3,NULL);
  2852.         }
  2853.        else if (object == (APTR)&Gadget8)
  2854.         dun = 1;
  2855.       }
  2856.      else
  2857.       {
  2858.        dun = 1;
  2859.       }
  2860.   }
  2861.  } while (!dun);
  2862.  CloseWindow(wG3);
  2863. // if (DEPTH >= 6)
  2864. //  {
  2865. //   SetRGB32(vP,1,tmp[0],tmp[1],tmp[2]);
  2866. //  }
  2867. // else
  2868. //  {
  2869. //   SetRGB4(vP,1,((tmp[0]>>8)&0xf),((tmp[0]>>4)&0xf),((tmp[0])&0xf));
  2870. //  }
  2871.  strcpy(str,Gadget6SIBuff);
  2872.  strcat (str," ");
  2873.  strcat(str,Gadget8SIBuff);
  2874.  SelectLevel(str);
  2875.  et = 0;
  2876.  dun = player;
  2877.  player = white;
  2878.  UpdateClocks();
  2879.  player = black;
  2880.  UpdateClocks();
  2881.  player = dun;
  2882. }
  2883.  
  2884.  
  2885.  
  2886. void DisplayError(str)
  2887. char *str;
  2888. {
  2889.  struct IntuiMessage __aligned *message;
  2890.  struct Window __aligned *wG3;
  2891.  char __aligned c2;
  2892.  char __aligned helpstr[64];
  2893.  BPTR __aligned mywindow;
  2894.  long __aligned temp;
  2895.  
  2896.  DisplayBeep(0L);
  2897.  if (wG)
  2898.   {
  2899.    if (!(wG3 = OpenWindow(&NewWindowStructure2)))
  2900.    {
  2901.     DisplayBeep(0L);
  2902.     return;
  2903.    }
  2904.    Move(wG3->RPort,2,25);
  2905.    Text(wG3->RPort,str,strlen(str));
  2906.    WaitPort(wG3->UserPort);
  2907.    while(message = (struct IntuiMessage *)GetMsg(wG3->UserPort))
  2908.     ReplyMsg((struct Message *)message);
  2909.    CloseWindow(wG3);
  2910.   }
  2911.  else
  2912.   { // open on wb screen
  2913.    (void)WBenchToFront();
  2914.    strcpy(helpstr,"RAW:120/10/400/100/Program Error");
  2915.    if (!(mywindow = Open(helpstr,MODE_NEWFILE)))
  2916.     {
  2917.      DisplayBeep(0L);
  2918.      return;
  2919.     }
  2920.    strcat(str,"\n\n\n");
  2921.    temp = strlen(str);
  2922.    if (Write(mywindow,str,temp) != temp)
  2923.     {
  2924.       DisplayBeep(0L);
  2925.       Close(mywindow);
  2926.       return;
  2927.     }
  2928.    strcpy(helpstr,"      Press any key to continue...");
  2929.    temp = strlen(helpstr);
  2930.    if (Write(mywindow,helpstr,temp) != temp)
  2931.     {
  2932.       DisplayBeep(0L);
  2933.       Close(mywindow);
  2934.       return;
  2935.     }
  2936.    Read(mywindow,&c2,1L);
  2937.    Close(mywindow);
  2938.   }
  2939. }
  2940.  
  2941. struct Library *LhBase;
  2942. struct LhBuffer *myLHBuffer;
  2943.  
  2944. int LoadBobData(void);
  2945. void FreeBobData(void);
  2946. int InitmyGels(void);
  2947. void CloseGels(void);
  2948.  
  2949.  
  2950. void LoadBobImage(piece)
  2951. long piece; /* loads bob with pieces image */
  2952. {
  2953.  int i;
  2954.  UWORD *temp;
  2955.  LONG image_data;
  2956.  WORD planes = RASSIZE (BOBWIDTH, BOBHEIGHT);
  2957.  
  2958.  if (piece == BLANKDATA)
  2959.   {
  2960.    temp = BlankImageData;
  2961.   }
  2962.  else if (piece >= 'a') /* white pieces */
  2963.   {
  2964.    if (piece == 'p')
  2965.     temp = WhiteImageData[0];
  2966.    else if (piece == 'n')
  2967.     temp = WhiteImageData[1];
  2968.    else if (piece == 'b')
  2969.     temp = WhiteImageData[2];
  2970.    else if (piece == 'r')
  2971.     temp = WhiteImageData[3];
  2972.    else if (piece == 'q')
  2973.     temp = WhiteImageData[4];
  2974.    else if (piece == 'k')
  2975.     temp = WhiteImageData[5];
  2976.   }
  2977.  else /* black pieces */
  2978.   {
  2979.    if (piece == 'P')
  2980.     temp = BlackImageData[0];
  2981.    else if (piece == 'N')
  2982.     temp = BlackImageData[1];
  2983.    else if (piece == 'B')
  2984.     temp = BlackImageData[2];
  2985.    else if (piece == 'R')
  2986.     temp = BlackImageData[3];
  2987.    else if (piece == 'Q')
  2988.     temp = BlackImageData[4];
  2989.    else if (piece == 'K')
  2990.     temp = BlackImageData[5];
  2991.   }
  2992.  BobImage.ImageData = BobVSprite->ImageData = temp;
  2993.  image_data = (LONG) BobImage.ImageData;
  2994.  /* Map the image data to planes */
  2995.  for (i = 0L; i < BOBDEPTH; ++i)
  2996.   BobTransImage->ti_BM.Planes[i] = (PLANEPTR) (image_data + i * planes);
  2997.  temp += (BOBHEIGHT*BOBDEPTH*BOBWIDINW);
  2998.  TheBob->ImageShadow = BobVSprite->CollMask = temp;
  2999.  temp += ((BOBHEIGHT+2)*BOBWIDINW);
  3000.  BobVSprite->BorderLine = temp;
  3001.  BobImage.ImageData = BobVSprite->ImageData;
  3002.  BobTransImage->ti_sBM->Planes[0] = (char *)TheBob->ImageShadow;
  3003.  for (i = 1; i < BOBDEPTH; i++)
  3004.    BobTransImage->ti_sBM->Planes[i] = BobTransImage->ti_sBM->Planes[0];
  3005.  lastpiece = piece;
  3006. }
  3007.  
  3008. int LoadBobData()
  3009. {
  3010.  USHORT __aligned len;
  3011.  long __aligned templong;
  3012.  BPTR fh;
  3013.  UBYTE *srcbuf;
  3014.  int i;
  3015.  
  3016.  if (!(srcbuf = AllocMem(BOBBLOCKSIZE,0L)))
  3017.   {
  3018.    return(0);
  3019.   }
  3020.  if (DEPTH < 6)
  3021.   {
  3022.    if (!(fh = Open("uchess:Pieces.lzw",MODE_OLDFILE)))
  3023.     {
  3024.     return(0);
  3025.    }
  3026.   }
  3027.  else if (FasterDisplay)
  3028.   {
  3029.    if (!(fh = Open("uchess:Pieces64.lzw",MODE_OLDFILE)))
  3030.     {
  3031.     return(0);
  3032.    }
  3033.   }
  3034.  else
  3035.   {
  3036.    if (!(fh = Open("uchess:Pieces256.lzw",MODE_OLDFILE)))
  3037.     {
  3038.     return(0);
  3039.    }
  3040.   }
  3041.  if (!(LhBase = OpenLibrary(LH_NAME,LH_VERSION)))
  3042.   {
  3043.    DisplayError("Cannot open lh.lib\n");
  3044.    return(0);
  3045.   }
  3046.  if (!(myLHBuffer = CreateBuffer(TRUE))) /* small buffer for only decomp*/
  3047.   {
  3048.    DisplayError("Cannot Create Buffer\n");
  3049.    CloseLibrary(LhBase);
  3050.    return(0);
  3051.   }
  3052.  for(i=0;i<6;i++)
  3053.   {
  3054.    if (Read(fh,(char *)&len,2L) != 2L)
  3055.     {
  3056.      Close(fh);
  3057.      return(0);
  3058.     }
  3059.    templong = len;
  3060.    if (Read(fh,srcbuf,templong) != templong)
  3061.     {
  3062.      Close(fh);
  3063.      return(0);
  3064.     }
  3065.    if (!(WhiteImageData[i] = 
  3066.         (UWORD *)AllocMem(BOBBLOCKSIZE,MEMF_CHIP|MEMF_CLEAR)))
  3067.     {
  3068.      return(0);
  3069.     }
  3070.    LoadBobImage(piecechar[i]);
  3071.    myLHBuffer->lh_Src = (APTR)srcbuf;
  3072.    myLHBuffer->lh_Dst = (APTR)BobVSprite->ImageData;
  3073.    myLHBuffer->lh_SrcSize = templong;
  3074.    myLHBuffer->lh_DstSize = BOBBLOCKSIZE;
  3075.    LhDecode(myLHBuffer);
  3076.    InitMasks(BobVSprite);
  3077.    if (Read(fh,(char *)&len,2L) != 2L)
  3078.     {
  3079.      Close(fh);
  3080.      return(0);
  3081.     }
  3082.    templong = len;
  3083.    if (Read(fh,srcbuf,templong) != templong)
  3084.     {
  3085.      Close(fh);
  3086.      return(0);
  3087.     }
  3088.    if (!(BlackImageData[i] = 
  3089.         (UWORD *)AllocMem(BOBBLOCKSIZE,MEMF_CHIP|MEMF_CLEAR)))
  3090.     {
  3091.      return(0);
  3092.     }
  3093.    LoadBobImage(piecechar[i+6]);
  3094.    myLHBuffer->lh_Src = (APTR)srcbuf;
  3095.    myLHBuffer->lh_Dst = (APTR)BobVSprite->ImageData;
  3096.    myLHBuffer->lh_SrcSize = templong;
  3097.    myLHBuffer->lh_DstSize = BOBBLOCKSIZE;
  3098.    LhDecode(myLHBuffer);
  3099.    InitMasks(BobVSprite);
  3100.   }
  3101.  Close(fh);
  3102.  FreeMem(srcbuf,BOBBLOCKSIZE);
  3103.  DeleteBuffer(myLHBuffer);
  3104.  CloseLibrary(LhBase);
  3105.  LoadBobImage(BLANKDATA);
  3106.  return(1);
  3107. }
  3108.  
  3109. void FreeBobData()
  3110. {
  3111.  int i;
  3112.  
  3113.  for(i=0;i<6;i++)
  3114.   {
  3115.    FreeMem((char *)WhiteImageData[i],BOBBLOCKSIZE);
  3116.    FreeMem((char *)BlackImageData[i],BOBBLOCKSIZE);
  3117.   }
  3118.  FreeMem((char *)BlankImageData,BOBBLOCKSIZE);
  3119. }
  3120.  
  3121. int InitmyGels()
  3122. {
  3123.  
  3124. #ifdef EXTRAINIT
  3125.  struct BitMap __aligned tmpBitMap;
  3126. #endif
  3127.  int i;
  3128.  UWORD *temp;
  3129.  
  3130.  if (!(SpriteHead = (struct VSprite *)
  3131.        AllocMem(sizeof(struct VSprite),MEMF_PUBLIC|MEMF_CLEAR)))
  3132.   {
  3133.    return(0);
  3134.   }
  3135.  if (!(SpriteTail = (struct VSprite *)
  3136.        AllocMem(sizeof(struct VSprite),MEMF_PUBLIC|MEMF_CLEAR)))
  3137.   {
  3138.    return(0);
  3139.   }
  3140.  if (!(BobVSprite = (struct VSprite *)
  3141.        AllocMem(sizeof(struct VSprite),MEMF_PUBLIC|MEMF_CLEAR)))
  3142.   {
  3143.    return(0);
  3144.   }
  3145.  if (!(TheBob = (struct Bob *)
  3146.        AllocMem(sizeof(struct Bob),MEMF_PUBLIC|MEMF_CLEAR)))
  3147.   {
  3148.    return(0);
  3149.   }
  3150.  if (!(myGelsInfo = (struct GelsInfo *)
  3151.        AllocMem(sizeof(struct GelsInfo),MEMF_PUBLIC|MEMF_CLEAR)))
  3152.   {
  3153.    return(0);
  3154.   }
  3155.  if (!(myGelsInfo->nextLine = (WORD *)AllocMem(sizeof(WORD)*32,
  3156.     MEMF_PUBLIC|MEMF_CLEAR)))
  3157.   {
  3158.    return(0);
  3159.   }
  3160.  if (!(myGelsInfo->lastColor = (WORD **)AllocMem(sizeof(WORD)*32,
  3161.     MEMF_PUBLIC|MEMF_CLEAR)))
  3162.   {
  3163.    return(0);
  3164.   }
  3165.  if (!(myGelsInfo->collHandler = (struct collTable *)
  3166.     AllocMem(sizeof(struct collTable),MEMF_PUBLIC|MEMF_CLEAR)))
  3167.   {
  3168.    return(0);
  3169.   }
  3170.  if (!(TheBob->SaveBuffer = (WORD *)
  3171.     AllocMem(sizeof(SHORT)*BOBWIDINW*BOBHEIGHT*BOBDEPTH,MEMF_CHIP|MEMF_CLEAR)))
  3172.   {
  3173.    return(0);
  3174.   }
  3175.  if (!(temp = BobVSprite->ImageData = 
  3176.         (UWORD *)AllocMem(BOBBLOCKSIZE,MEMF_CHIP|MEMF_CLEAR)))
  3177.     {
  3178.      return(0);
  3179.     }
  3180.  BlankImageData = temp;
  3181.  temp += (BOBHEIGHT*BOBDEPTH*BOBWIDINW);
  3182.  TheBob->ImageShadow = BobVSprite->CollMask = temp;
  3183.  temp += ((BOBHEIGHT+2)*BOBWIDINW);
  3184.  BobVSprite->BorderLine = temp;
  3185. #ifdef DBL_BUFF
  3186.  if (!(TheBob->DBuffer = (struct DBufPacket *)AllocMem
  3187.         (sizeof(struct DBufPacket),MEMF_CHIP|MEMF_CLEAR)))
  3188.     {
  3189.      return(0);
  3190.     }
  3191.  if (!(TheBob->DBuffer->BufBuffer = 
  3192.        (WORD *)AllocRaster(BOBWIDTH,BOBHEIGHT*BOBDEPTH)))
  3193.   {
  3194.      return(0);
  3195.   }
  3196. #endif
  3197.  
  3198.  BOBPLANEPICK = 1;
  3199.  for(i=0;i<DEPTH;i++)
  3200.   {
  3201.    BOBPLANEPICK *= 2;
  3202.   }
  3203.  BOBPLANEPICK--;
  3204.  BobImage.LeftEdge = 0;
  3205.  BobImage.TopEdge = 0;
  3206.  BobImage.Width = BOBWIDTH;
  3207.  BobImage.Height = BOBHEIGHT;
  3208.  BobImage.Depth = BOBDEPTH; 
  3209.  BobImage.ImageData = BobVSprite->ImageData;
  3210.  BobImage.PlanePick = BOBPLANEPICK;
  3211.  BobImage.PlaneOnOff = BOBPLANEONOFF;
  3212.  BobImage.NextImage = NULL;
  3213.  if (!(BobTransImage = AllocTransImage(&BobImage)))
  3214.   {
  3215.    return(0);
  3216.   }
  3217.  
  3218.  if (SYSTEM_BOBS)
  3219.   {
  3220.    myGelsInfo->leftmost = COLA;
  3221.    myGelsInfo->rightmost = COLH+BOBWIDTH+1;
  3222.    myGelsInfo->topmost = ROW8;
  3223.    myGelsInfo->bottommost = ROW1+BOBHEIGHT+1; 
  3224.    rpG->GelsInfo = myGelsInfo;
  3225.    InitGels((struct VSprite *)SpriteHead,SpriteTail,myGelsInfo);
  3226.    WaitTOF();
  3227.   }
  3228.  BobVSprite->Flags = SAVEBACK | OVERLAY;
  3229.  BobVSprite->X = WIDTH-1-BOBWIDTH;
  3230.  BobVSprite->Y = HEIGHT-1-BOBHEIGHT;  
  3231.  BobVSprite->Height = BOBHEIGHT;
  3232.  BobVSprite->Width = BOBWIDINW;
  3233.  BobVSprite->Depth = BOBDEPTH;
  3234.  BobVSprite->MeMask = BOBMEMASK;
  3235.  BobVSprite->HitMask = BOBHITMASK;
  3236.  BobVSprite->VSBob = TheBob;
  3237.  BobVSprite->PlanePick = BOBPLANEPICK;
  3238.  BobVSprite->PlaneOnOff = BOBPLANEONOFF;  
  3239.  BobVSprite->VUserExt = 0;
  3240.  TheBob->BobVSprite = BobVSprite;
  3241.  
  3242.  if (!LoadBobData())
  3243.   {
  3244.    DisplayError("Cannot Load BOB data\n");
  3245.    CloseWindow(wG);
  3246.    CloseScreen(sC);
  3247.   }
  3248.  
  3249.  
  3250.  InitMasks(BobVSprite);
  3251.  return(1);
  3252. }
  3253.  
  3254. void CloseGels()
  3255. {
  3256.      if (SYSTEM_BOBS)
  3257.       RemIBob(TheBob,rpG,vP);
  3258.      FreeBobData();
  3259.    
  3260. #ifdef DBL_BUFF
  3261.    FreeRaster((PLANEPTR)TheBob->DBuffer->BufBuffer,BOBWIDTH,BOBHEIGHT*BOBDEPTH);
  3262.    FreeMem((char *)TheBob->DBuffer,sizeof(struct DBufPacket));
  3263. #endif
  3264.    FreeTransImage(BobTransImage);
  3265.    FreeMem((char *)TheBob->SaveBuffer,
  3266.      sizeof(SHORT)*BOBWIDINW*BOBHEIGHT*BOBDEPTH);
  3267.    FreeMem((char *)myGelsInfo->collHandler,sizeof(struct collTable));
  3268.    FreeMem((char *)myGelsInfo->lastColor,sizeof(WORD)*32);
  3269.    FreeMem((char *)myGelsInfo->nextLine,sizeof(WORD)*32);
  3270.    FreeMem((char *)myGelsInfo,sizeof(struct GelsInfo));
  3271.    FreeMem((char *)TheBob,sizeof(struct Bob));
  3272.    FreeMem((char *)BobVSprite,sizeof(struct VSprite));
  3273.    FreeMem((char *)SpriteTail,sizeof(struct VSprite));
  3274.    FreeMem((char *)SpriteHead,sizeof(struct VSprite));
  3275. }
  3276.  
  3277. struct TransImage *
  3278. AllocTransImage (struct Image * im)
  3279. {
  3280.     if (im)
  3281.     {
  3282.     LONG msize = sizeof (struct TransImage);
  3283.     struct TransImage *ti;
  3284.  
  3285.     if (ti = (struct TransImage *) AllocMem (msize, MEMF_CLEAR))
  3286.     {
  3287.         LONG image_data = (LONG) im->ImageData;
  3288.         UWORD depth = im->Depth;
  3289.         UWORD width = im->Width;
  3290.         UWORD height = im->Height;
  3291.         WORD planes = RASSIZE (width, height);
  3292.         WORD i;
  3293.  
  3294.         /* Remember the image */
  3295.         ti->ti_IM = im;
  3296.  
  3297.         /* Initialize the Image bitmap */
  3298.         InitBitMap (&ti->ti_BM, depth, width, height);
  3299.  
  3300.         /* Map the image data to planes */
  3301.         for (i = 0L; i < depth; ++i)
  3302.         ti->ti_BM.Planes[i] = (PLANEPTR) (image_data + i * planes);
  3303.  
  3304.         /* Initialize the Image rastport */
  3305.         InitRastPort (&ti->ti_RP);
  3306.         ti->ti_RP.BitMap = &ti->ti_BM;
  3307.  
  3308.         if (ti->ti_sBM = AllocShadowBM (depth, width, height))
  3309.         {
  3310.         if (ti->ti_sRP = AllocShadowRP (ti->ti_sBM))
  3311.         {
  3312.             return (ti);
  3313.         }
  3314.         FreeShadowBM (ti->ti_sBM);
  3315.         }
  3316.         FreeMem ((APTR) ti, msize);
  3317.     }
  3318.     }
  3319.  
  3320.     return (NULL);
  3321. }
  3322.  
  3323. VOID
  3324. FreeTransImage (struct TransImage * ti)
  3325. {
  3326.  
  3327.     if (ti)
  3328.     {
  3329.     LONG msize = sizeof (struct TransImage);
  3330.  
  3331.     /* Free the shadow RastPort */
  3332.     FreeShadowRP (ti->ti_sRP);
  3333.  
  3334.     /* Free the shadow BitMap */
  3335.     FreeShadowBM (ti->ti_sBM);
  3336.  
  3337.     /* Free the temporary buffer */
  3338.     FreeMem ((APTR) ti, msize);
  3339.     }
  3340. }
  3341.  
  3342. VOID
  3343. FreeShadowBM (struct BitMap *sbm)
  3344. {
  3345.  
  3346.     if (sbm)
  3347.     {
  3348.  
  3349. #ifdef ALLOCFORREAL
  3350.     LONG msize;
  3351.  
  3352.     msize = RASSIZE (8 * (sbm->BytesPerRow), sbm->Rows);
  3353.  
  3354.  
  3355.  
  3356.     if (sbm->Planes[0])
  3357.     {
  3358.         FreeMem ((APTR)sbm->Planes[0], msize);
  3359.     }
  3360. #else
  3361.  
  3362.     FreeMem ((APTR)sbm, sizeof (struct BitMap));
  3363. #endif
  3364.     }
  3365. }
  3366.  
  3367. VOID
  3368. FreeShadowRP (struct RastPort *srp)
  3369. {
  3370.  
  3371.     if (srp)
  3372.     {
  3373.     FreeMem (srp, sizeof (struct RastPort));
  3374.     }
  3375. }
  3376.  
  3377. struct BitMap *
  3378. AllocShadowBM (UWORD depth, UWORD width, UWORD height)
  3379. {
  3380.     LONG msize = sizeof (struct BitMap);
  3381.     struct BitMap *bm;
  3382.     WORD i;
  3383.  
  3384.     /* Allocate a bitmap */
  3385.     if (bm = (struct BitMap *) AllocMem (msize, MEMF_CLEAR))
  3386.     {
  3387. #ifdef ALLOCFORREAL
  3388.     LONG rsize = RASSIZE (width, height);
  3389. #endif
  3390.  
  3391.     /* Initialize the bitmap */
  3392.     InitBitMap (bm, depth, width, height);
  3393.  
  3394. #ifdef ALLOCFORREAL
  3395.     /* Allocate one plane */
  3396.     if (bm->Planes[0] = (PLANEPTR) AllocMem (rsize, MEMF_CHIP | MEMF_CLEAR))
  3397.     {
  3398.         /* All planes point to the first plane */
  3399.         for (i = 1; i < depth; i++)
  3400.         bm->Planes[i] = bm->Planes[0];
  3401.  
  3402.         return (bm);
  3403.     }
  3404.  
  3405.     FreeMem ((APTR) bm, msize);
  3406. #else
  3407.      bm->Planes[0] = (char *)TheBob->ImageShadow;
  3408.      for (i = 1; i < depth; i++)
  3409.     bm->Planes[i] = bm->Planes[0];
  3410.      return (bm);
  3411. #endif
  3412.     }
  3413.     return (NULL);
  3414. }
  3415.  
  3416. struct RastPort *
  3417. AllocShadowRP (struct BitMap *bm)
  3418. {
  3419.     LONG msize = sizeof (struct RastPort);
  3420.     struct RastPort *rp;
  3421.  
  3422.     /* Allocate a RastPort */
  3423.     if (rp = (struct RastPort *) AllocMem (msize, MEMF_CHIP))
  3424.     {
  3425.     /* Initialize the new RastPort */
  3426.     InitRastPort (rp);
  3427.  
  3428.     /* Point the RastPort's BitMap... */
  3429.     rp->BitMap = bm;
  3430.     }
  3431.  
  3432.     return (rp);
  3433. }
  3434.  
  3435.  
  3436. VOID
  3437. ClipBlitTrans (
  3438.     struct RastPort *rp,    /* source RastPort */
  3439.     WORD sx, WORD sy,        /* source top-left edge */
  3440.     struct RastPort *drp,    /* destination RastPort */
  3441.     WORD dx, WORD dy,        /* destination top-left edge */
  3442.     WORD width, WORD height,    /* width & height of image to blit */
  3443.     struct RastPort *Srp)    /* shadow RastPort */
  3444. {
  3445.  
  3446.     /* make the shadow */
  3447.     ClipBlit (rp, sx, sy, Srp, 0, 0, width, height, 0xe0);
  3448.     ClipBlit (Srp, 0, 0, drp, dx, dy, width, height, 0x20); /* blit cookie cutter outline */
  3449.     ClipBlit (rp, sx, sy, drp, dx, dy, width, height, 0xe0); /* now fill in image */
  3450. }
  3451.  
  3452.  
  3453. int LoadFullBitMap(void);
  3454.  
  3455. int LoadFullBitMap()
  3456. {
  3457.  unsigned long i;
  3458.  char errstr[40];
  3459.  char fname[80];
  3460.  long count;
  3461.  USHORT len;
  3462.  char *srcbuf;
  3463.  ULONG tt;
  3464.  BPTR fh;
  3465.  BPTR __aligned fp;
  3466.  struct BitMap *tmpBitMap;
  3467.  struct BitMap *PlanarBitMap;
  3468.  struct FileInfoBlock __aligned *myFileInfoBlock;
  3469. //LONG tmp1,tmp2;
  3470. //char tstr[40];
  3471.  
  3472.  if (DEPTH < 6)
  3473.   strcpy(fname,"uchess:Chess.lzw");
  3474.  else if (FasterDisplay)
  3475.   strcpy(fname,"uchess:Chess64.lzw");
  3476.  else
  3477.   strcpy(fname,"uchess:Chess256.lzw");
  3478.  
  3479.  
  3480.   if (!(myFileInfoBlock = 
  3481.      (struct FileInfoBlock *)AllocMem(sizeof(struct FileInfoBlock),MEMF_PUBLIC)))
  3482.    {
  3483.      DisplayError("No Mem now for finfo block");
  3484.      return(0);
  3485.    }
  3486.   if (!(fp = Lock(fname,ACCESS_READ)))
  3487.    {
  3488.      FreeMem((char *)myFileInfoBlock,sizeof(struct FileInfoBlock));
  3489.      return(0);
  3490.    }
  3491.   if (!(Examine(fp,myFileInfoBlock)))
  3492.    {
  3493.      DisplayError("Cannot get finfo");
  3494.      UnLock(fp);
  3495.      FreeMem((char *)myFileInfoBlock,sizeof(struct FileInfoBlock));
  3496.      return(0);
  3497.    }
  3498.   UnLock(fp);
  3499.   count = myFileInfoBlock->fib_Size - 2L;
  3500.   FreeMem((char *)myFileInfoBlock,sizeof(struct FileInfoBlock));
  3501.  
  3502.  
  3503. /* before unpacking the bitmap, save the titlebar area in a tmp bitmap */
  3504.  if (!RTG)
  3505.   {
  3506.    if (!(tmpBitMap = tAllocBitMap(WIDTH,MENUBARHT,DEPTH,BMF_CLEAR,myBitMap)))
  3507.     {
  3508.      return(0);
  3509.     }
  3510.    BltBitMap(myBitMap,0,0,tmpBitMap,0L,0L,WIDTH,MENUBARHT,0xc0L,0xffL,0L);
  3511.   }
  3512.  else
  3513.   {
  3514.    if (!(tmpBitMap = tAllocBitMap(WIDTH,MENUBARHT,DEPTH,BMF_CLEAR,0L)))
  3515.     {
  3516.      return(0);
  3517.     }
  3518.    BltBitMap(sC->RastPort.BitMap,0,0,tmpBitMap,0L,0L,WIDTH,MENUBARHT,0xc0L,0xffL,0L);
  3519.   }
  3520.  if (!(srcbuf = AllocMem(count,0L)))
  3521.   {
  3522.    sprintf(errstr,"Cannot allocate lharc %d byte buffer",count);
  3523.    DisplayError(errstr);
  3524.    return(0);
  3525.   }
  3526.  if (!(LhBase = OpenLibrary(LH_NAME,LH_VERSION)))
  3527.   {
  3528.    DisplayError("Cannot open lh.lib");
  3529.    return(0);
  3530.   }
  3531.  if (!(myLHBuffer = CreateBuffer(TRUE))) /* small buffer for only decomp*/
  3532.   {
  3533.    DisplayError("Cannot Create Buffer");
  3534.    CloseLibrary(LhBase);
  3535.    return(0);
  3536.   }
  3537.  
  3538.    if (!(fh = Open(fname,MODE_OLDFILE)))
  3539.     {
  3540.      DisplayError("Cannot open chess file");
  3541.      return(0);
  3542.     }
  3543.    if (Read(fh,(char *)&len,2L) != 2L)
  3544.     {
  3545.      DisplayError("Cannot read chess file");
  3546.      Close(fh);
  3547.      return(0);
  3548.     }
  3549.    if (Read(fh,srcbuf,count) != count)
  3550.     {
  3551.      DisplayError("Cannot read chess file2");
  3552.      Close(fh);
  3553.      return(0);
  3554.     }
  3555.    Close(fh);
  3556.    if ((RTG)&&(!OrigmyBitMap))
  3557.     { // allocate the BitMap to unpack to
  3558.      if (!(OrigmyBitMap = myBitMap = sAllocBitMap(WIDTH,HEIGHT,DEPTH,BMF_INTERLEAVED|BMF_CLEAR|BMF_DISPLAYABLE,
  3559.                        0L)))
  3560.       {
  3561.        return(0);
  3562.       }
  3563.     }
  3564. //sprintf(tstr," BytesPerRow = %d",myBitMap->BytesPerRow);
  3565. //DisplayError(tstr);
  3566. //sprintf(tstr," Rows = %d",myBitMap->Rows);
  3567. //DisplayError(tstr);
  3568. //sprintf(tstr," Flags = %d",myBitMap->Flags);
  3569. //DisplayError(tstr);
  3570. //sprintf(tstr," Depth = %d",myBitMap->Depth);
  3571. //DisplayError(tstr);
  3572. //sprintf(tstr," pad  = %d",myBitMap->pad);
  3573. //DisplayError(tstr);
  3574.  
  3575. //for(i=0;i<7;i++)
  3576. // {
  3577. //  tmp1 =(ULONG) myBitMap->Planes[i];
  3578. //  tmp2 = (ULONG)myBitMap->Planes[i+1];
  3579. //  sprintf(tstr," diff = %08x",(tmp2 - tmp1));
  3580. //  DisplayError(tstr);
  3581. // }
  3582.    myLHBuffer->lh_Src = (APTR)srcbuf;
  3583.    myLHBuffer->lh_Dst = (APTR)myBitMap->Planes[0];
  3584.    myLHBuffer->lh_SrcSize = count;
  3585.    tt = WIDTH/8L;
  3586.    tt = tt*HEIGHT;
  3587.    tt = tt*DEPTH;
  3588.    myLHBuffer->lh_DstSize = tt;
  3589.    LhDecode(myLHBuffer);
  3590.  
  3591.  FreeMem(srcbuf,count); 
  3592.  DeleteBuffer(myLHBuffer);
  3593.  CloseLibrary(LhBase);
  3594.  BltBitMap(tmpBitMap,0,0,myBitMap,0L,0L,WIDTH,MENUBARHT,0xc0L,0xffL,0L);
  3595.  tFreeBitMap(tmpBitMap);
  3596.  if (RTG)
  3597.   {
  3598.      if (!(PlanarBitMap = tAllocBitMap(WIDTH,HEIGHT/10,DEPTH,BMF_CLEAR,0L)))
  3599.       {
  3600.        return(0);
  3601.       }
  3602.      for(i=0;i<10;i++)
  3603.       {
  3604.        BltBitMap(myBitMap,0,(i*(HEIGHT/10)),PlanarBitMap,0,0,WIDTH,(HEIGHT/10),0xc0L,0xffL,0L);
  3605.        BltBitMap(PlanarBitMap,0,0,sC->RastPort.BitMap,0,(i*(HEIGHT/10)),WIDTH,(HEIGHT/10),0xc0L,0xffL,0L);
  3606.       }
  3607.      // then free the non-interleaved bitmap...
  3608.      tFreeBitMap(PlanarBitMap);
  3609.   }
  3610.  
  3611.  mySetABPenDrMd(rpG,BLACK,bpen,JAM1);
  3612.  Move(rpG,511,COMPUTERBOX-10);
  3613. #ifdef _M68040
  3614.  strcpy(fname,"UChess Pro:");
  3615. #else
  3616. #ifndef TINYCHESS
  3617.  strcpy(fname,"UChess Jr.:");
  3618. #else
  3619.  strcpy(fname,"UChess Tiny:");
  3620. #endif
  3621. #endif
  3622.  Text(rpG,fname,strlen(fname));
  3623.  Move(rpG,511,USERBOX-10);
  3624.  strcpy(fname,"Puny Human:");
  3625.  Text(rpG,fname,strlen(fname));
  3626.  if (!RTG)
  3627.   {
  3628.    BltBitMap(myBitMap,COLB,ROW5,WhiteBitMap,0L,0L,SQUAREWIDTH,SQUAREHEIGHT,0xc0L,0xffL,0L);
  3629.    BltBitMap(myBitMap,COLA,ROW5,BlackBitMap,0L,0L,SQUAREWIDTH,SQUAREHEIGHT,0xc0L,0xffL,0L);
  3630.   }
  3631.  else
  3632.   {
  3633.    BltBitMap(sC->RastPort.BitMap,COLB,ROW5,WhiteBitMap,0L,0L,SQUAREWIDTH,SQUAREHEIGHT,0xc0L,0xffL,0L);
  3634.    BltBitMap(sC->RastPort.BitMap,COLA,ROW5,BlackBitMap,0L,0L,SQUAREWIDTH,SQUAREHEIGHT,0xc0L,0xffL,0L);
  3635.   }
  3636.  RethinkDisplay();
  3637.  if (RTG)
  3638.   {
  3639.    myBitMap = sC->RastPort.BitMap;
  3640.    sFreeBitMap(OrigmyBitMap);
  3641.    OrigmyBitMap = 0L;
  3642.   }
  3643.  if (!textBitMap)
  3644.   {
  3645.    if (!(textBitMap = tAllocBitMap(160,160,DEPTH,BMF_CLEAR,myBitMap)))
  3646.     {
  3647.      DisplayBeep(0L);
  3648.      Delay(10L);
  3649.      DisplayBeep(0L);
  3650.      Delay(15L);
  3651.      DisplayBeep(0L);
  3652.      Delay(25L);
  3653.      DisplayBeep(0L);
  3654.      return(0);
  3655.     }
  3656.   }
  3657.  return(1);
  3658. }
  3659.  
  3660.  
  3661. int mAllocBitMap(void);
  3662.  
  3663. int mAllocBitMap()
  3664. {
  3665.  
  3666.  if (!RTG)
  3667.   {
  3668.    if (!(OrigmyBitMap = myBitMap = tAllocBitMap(WIDTH,HEIGHT,DEPTH,BMF_INTERLEAVED|BMF_CLEAR|BMF_DISPLAYABLE,
  3669.                     0L)))
  3670.     {
  3671.      return(0);
  3672.     }
  3673.   }
  3674.  else
  3675.   {
  3676.    if (!(OrigmyBitMap = myBitMap = sAllocBitMap(WIDTH,HEIGHT,DEPTH,BMF_INTERLEAVED|BMF_CLEAR|BMF_DISPLAYABLE,
  3677.                     0L)))
  3678.     {
  3679.      return(0);
  3680.     }
  3681.   }
  3682.  if (RTG)
  3683.   {
  3684.    if ((RTG_ModeID == VGAPRODUCT_KEY)||
  3685.        (RTG_ModeID == (HIRES|LACE|DEFAULT_MONITOR_ID))||
  3686.        (RTG_ModeID == (HIRES|LACE|PAL_MONITOR_ID))|| 
  3687.        (RTG_ModeID == (HIRES|LACE|NTSC_MONITOR_ID)) || 
  3688.        (RTG_ModeID == (HIRES|LACE|DBLPAL_MONITOR_ID))|| 
  3689.        (RTG_ModeID == (HIRES|LACE|DBLNTSC_MONITOR_ID)) || 
  3690.        (RTG_ModeID == (LORES_KEY|LACE|DEFAULT_MONITOR_ID))|| 
  3691.        (RTG_ModeID == (LORES_KEY|LACE|PAL_MONITOR_ID))|| 
  3692.        (RTG_ModeID == (LORES_KEY|LACE|NTSC_MONITOR_ID)) || 
  3693.        (RTG_ModeID == (LORES_KEY|LACE|DBLPAL_MONITOR_ID))|| 
  3694.        (RTG_ModeID == (LORES_KEY|LACE|DBLNTSC_MONITOR_ID)) || 
  3695.        (RTG_ModeID == (HIRES|DEFAULT_MONITOR_ID))||
  3696.        (RTG_ModeID == (HIRES|PAL_MONITOR_ID))|| 
  3697.        (RTG_ModeID == (HIRES|NTSC_MONITOR_ID)) || 
  3698.        (RTG_ModeID == (HIRES|DBLNTSC_MONITOR_ID)) || 
  3699.        (RTG_ModeID == (HIRES|DBLPAL_MONITOR_ID)) || 
  3700.        (RTG_ModeID == (LORES_KEY|DEFAULT_MONITOR_ID))|| 
  3701.        (RTG_ModeID == (LORES_KEY|PAL_MONITOR_ID))|| 
  3702.        (RTG_ModeID == (LORES_KEY|NTSC_MONITOR_ID)) || 
  3703.        (RTG_ModeID == (LORES_KEY|DBLPAL_MONITOR_ID)) || 
  3704.        (RTG_ModeID == (LORES_KEY|DBLNTSC_MONITOR_ID)) || 
  3705.        (RTG_ModeID == (SUPER72_MONITOR_ID | SUPERLACE_KEY)))
  3706.      {
  3707.       myTagList[3].ti_Tag = SA_Interleaved;
  3708.       myTagList[3].ti_Data = TRUE;
  3709.      }
  3710.    NewScreenStructure.Type = CUSTOMSCREEN | NS_EXTENDED; // no custom bitmap
  3711.    NewScreenStructure.CustomBitMap = 0L;
  3712.    if (!(WhiteBitMap = tAllocBitMap(ROUNDEDSQUAREWIDTH,SQUAREHEIGHT,DEPTH,
  3713.                         BMF_CLEAR,0L)))
  3714.     {
  3715.      return(0);
  3716.     }
  3717.    if (!(BlackBitMap = tAllocBitMap(ROUNDEDSQUAREWIDTH,SQUAREHEIGHT,DEPTH,
  3718.                           BMF_CLEAR,0L)))
  3719.     {
  3720.      return(0);
  3721.     }
  3722.   }
  3723.  else
  3724.   {
  3725.    NewScreenStructure.CustomBitMap = myBitMap;
  3726.    if (!(WhiteBitMap = tAllocBitMap(ROUNDEDSQUAREWIDTH,SQUAREHEIGHT,DEPTH,
  3727.                         BMF_CLEAR,myBitMap)))
  3728.     {
  3729.      return(0);
  3730.     }
  3731.    if (!(BlackBitMap = tAllocBitMap(ROUNDEDSQUAREWIDTH,SQUAREHEIGHT,DEPTH,
  3732.                           BMF_CLEAR,myBitMap)))
  3733.     {
  3734.      return(0);
  3735.     }
  3736.   }
  3737.  return(1);
  3738. }
  3739.  
  3740. void FreeTheBitMap(void);
  3741.  
  3742. void FreeTheBitMap()
  3743. {
  3744.  tFreeBitMap(BlackBitMap);
  3745.  tFreeBitMap(WhiteBitMap);
  3746.  if (OrigmyBitMap)
  3747.   if (!RTG)
  3748.    tFreeBitMap(OrigmyBitMap);
  3749.   else
  3750.    sFreeBitMap(OrigmyBitMap);
  3751.  if (textBitMap)
  3752.   tFreeBitMap(textBitMap);
  3753. }
  3754.  
  3755. void AmigaShutDown(void);
  3756. int AmigaStartup(void);
  3757.  
  3758. int AmigaStarted = 0;
  3759.  
  3760. int AmigaStartup()
  3761. {
  3762.     flag.post = false;
  3763.         if (!(myTextFont = OpenFont(&TOPAZ80)))
  3764.          {
  3765.       return(0);
  3766.          }
  3767.         if (gfxversion < 39)
  3768.          DEPTH = 4;
  3769.         else if (RTG)
  3770.          { // use screen requestor to ask guy what he wants
  3771.           if (!GetScreenMode())
  3772.            {
  3773.              return(0);
  3774.            }
  3775.           DEPTH = 8; // only support 8 bit RTG screens
  3776.           myTagList[0].ti_Data = RTG_ModeID;
  3777.       myTagList[2].ti_Tag = SA_AutoScroll;
  3778.           myTagList[2].ti_Data = TRUE;
  3779.          }
  3780.         else
  3781.          {
  3782.           if (v15Khz)
  3783.            {
  3784.             myTagList[0].ti_Data = HIRES|LACE|DEFAULT_MONITOR_ID;
  3785.             myTagList[2].ti_Data = TRUE;
  3786.             myTagList[2].ti_Tag = SA_AutoScroll;
  3787.            }
  3788.           if (Super72)
  3789.            myTagList[0].ti_Data = (SUPER72_MONITOR_ID | SUPERLACE_KEY);
  3790.           NewScreenStructure2.Type |= NS_EXTENDED;
  3791.           NewScreenStructure2.Extension = myTagList;
  3792.           NewScreenStructure2.Height = 480;
  3793.           NewScreenStructure2.Depth = 8; 
  3794.           NewScreenStructure2.BlockPen = 251;
  3795.       if ((sC = OpenScreen((struct NewScreen *)&NewScreenStructure2)))
  3796.            {
  3797.             CloseScreen(sC);
  3798.             DEPTH = 8;
  3799.            }
  3800.           else
  3801.            {
  3802.             myTagList[0].ti_Data = HIRES|LACE|DEFAULT_MONITOR_ID;
  3803.         myTagList[2].ti_Tag = SA_AutoScroll;
  3804.             myTagList[2].ti_Data = TRUE;
  3805.         if ((sC = OpenScreen((struct NewScreen *)&NewScreenStructure2)))
  3806.              {
  3807.               CloseScreen(sC);
  3808.               DEPTH = 8;
  3809.              }
  3810.             else
  3811.              {
  3812.             myTagList[2].ti_Tag = 0;
  3813.               myTagList[2].ti_Data = 0;
  3814.               myTagList[0].ti_Data = HIRES|LACE;
  3815.               DEPTH = 4;
  3816.              }
  3817.            }
  3818.          }
  3819.         if (DEPTH == 8)
  3820.          {
  3821.           BLACK = 2;
  3822.           if (FasterDisplay)
  3823.            {
  3824.             DEPTH = 6;
  3825.             MBLOCKPEN = 0;//61;
  3826.             BACKGNDTEXTCOLOR = 57;
  3827.             BACKPEN =61;
  3828.            }
  3829.           else
  3830.            {
  3831.             MBLOCKPEN = 0;//251;
  3832.             BACKGNDTEXTCOLOR = 0xe0;
  3833.             BACKPEN = 251;
  3834.            }
  3835.       TIMEYCOORD1 = 120;
  3836.       TIMEYCOORD2 = 230;
  3837.           USERBOX=168;
  3838.           SYSTEMBOX = USERBOX + 112;
  3839.           SYSBOXLEN = 102;
  3840.           COMPUTERBOX=60;
  3841.           BOBDEPTH = DEPTH;
  3842.           ROW8 = 24;
  3843.           BOBHEIGHT = 55;
  3844.           HEIGHT = 480;
  3845.           NewScreenStructure.Type |= NS_EXTENDED;
  3846.           NewScreenStructure.Extension = myTagList;
  3847.           NewScreenStructure.Height = HEIGHT;
  3848.           NewScreenStructure.Depth = DEPTH;
  3849.           NewScreenStructure.BlockPen = BACKPEN;
  3850.           NewWindowStructure1.Height = HEIGHT;
  3851.           NewWindowStructure1.MaxHeight = HEIGHT;
  3852.           NewWindowStructure1.BlockPen = BACKPEN;
  3853.           NewWindowStructure2.BlockPen = BACKPEN;
  3854.           NewWindowStructure5.BlockPen = BACKPEN;
  3855.           NewWindowStructure6.BlockPen = BACKPEN;
  3856.           pNewWindowStructure1.BlockPen = BACKPEN;
  3857.           Border6.FrontPen = Border7.FrontPen = 
  3858.           Border9.FrontPen = Border1.FrontPen = BACKPEN;
  3859.           aBorder1.FrontPen = aBorder2.FrontPen = 
  3860.           aBorder3.FrontPen = aBorder4.FrontPen = 
  3861.           pBorder1.FrontPen = pBorder2.FrontPen = 
  3862.           pBorder3.FrontPen = pBorder4.FrontPen = BACKPEN;
  3863.           pIText1.FrontPen = 
  3864.           pIText2.FrontPen = 
  3865.           pIText2a.FrontPen = 
  3866.           pIText3.FrontPen = 
  3867.           pIText4.FrontPen = 
  3868.           pIText5.FrontPen = 
  3869.           pIText6.FrontPen = 
  3870.           pIText7.FrontPen = 
  3871.           pIText8a.FrontPen = 
  3872.           IText93.FrontPen = 
  3873.           IText47.FrontPen = 
  3874.           IText46.FrontPen = 
  3875.           IText37.FrontPen = 
  3876.           IText1.FrontPen = 
  3877.           IText1r.FrontPen = 
  3878.           IText2.FrontPen = 
  3879.           IText2x.FrontPen = 
  3880.           IText3.FrontPen = 
  3881.           IText4.FrontPen = 
  3882.           IText4aa.FrontPen = 
  3883.           IText4ab.FrontPen = 
  3884.           IText4cc.FrontPen = 
  3885.           IText4dd.FrontPen = 
  3886.           IText4ee.FrontPen = 
  3887.           IText4a.FrontPen = 
  3888.           IText5.FrontPen = 
  3889.           IText6.FrontPen = 
  3890.           IText7.FrontPen = 
  3891.           IText8.FrontPen = 
  3892.           IText9.FrontPen = 
  3893.           IText10.FrontPen = 
  3894.           IText11.FrontPen = 
  3895.           IText12.FrontPen = 
  3896.           IText13.FrontPen = 
  3897.           IText13a.FrontPen = 
  3898.           IText14.FrontPen = 
  3899.           IText15.FrontPen = 
  3900.           IText16.FrontPen = 
  3901.           IText22.FrontPen = 
  3902.           IText21.FrontPen = 
  3903.           IText20.FrontPen = 
  3904.           IText19.FrontPen = 
  3905.           IText18.FrontPen = 
  3906.           aIText1.FrontPen = 
  3907.           aIText2.FrontPen = 
  3908.           aIText3.FrontPen = 
  3909.           aIText4.FrontPen = 
  3910.           aIText5.FrontPen = 
  3911.           IText17.FrontPen = BACKPEN;
  3912.  
  3913.           IText37.BackPen = 
  3914.           IText1.BackPen = 
  3915.           IText1r.BackPen = 
  3916.           IText2.BackPen = 
  3917.           IText2x.BackPen = 
  3918.           IText3.BackPen = 
  3919.           IText4.BackPen = 
  3920.           IText4aa.BackPen = 
  3921.           IText4ab.BackPen = 
  3922.           IText4cc.BackPen = 
  3923.           IText4dd.BackPen = 
  3924.           IText4ee.BackPen = 
  3925.           IText4a.BackPen = 
  3926.           IText5.BackPen = 
  3927.           IText6.BackPen = 
  3928.           IText7.BackPen = 
  3929.           IText8.BackPen = 
  3930.           IText9.BackPen = 
  3931.           IText10.BackPen = 
  3932.           IText11.BackPen = 
  3933.           IText12.BackPen = 
  3934.           IText13.BackPen = 
  3935.           IText13a.BackPen = 
  3936.           IText14.BackPen = 
  3937.           IText15.BackPen = BACKPEN;
  3938.  
  3939.           IText37.FrontPen = 
  3940.           IText1.FrontPen = 
  3941.           IText1r.FrontPen = 
  3942.           IText2.FrontPen = 
  3943.           IText2x.FrontPen = 
  3944.           IText3.FrontPen = 
  3945.           IText4.FrontPen = 
  3946.           IText4aa.FrontPen = 
  3947.           IText4ab.FrontPen = 
  3948.           IText4cc.FrontPen = 
  3949.           IText4dd.FrontPen = 
  3950.           IText4ee.FrontPen = 
  3951.           IText4a.FrontPen = 
  3952.           IText5.FrontPen = 
  3953.           IText6.FrontPen = 
  3954.           IText7.FrontPen = 
  3955.           IText8.FrontPen = 
  3956.           IText9.FrontPen = 
  3957.           IText10.FrontPen = 
  3958.           IText11.FrontPen = 
  3959.           IText12.FrontPen = 
  3960.           IText13.FrontPen = 
  3961.           IText13a.FrontPen = 
  3962.           IText14.FrontPen = 
  3963.           IText15.FrontPen = MBLOCKPEN;
  3964.          }
  3965.         if (!(mAllocBitMap()))
  3966.          {
  3967.           CloseFont(myTextFont);
  3968.           return(0);
  3969.          }
  3970.         RowArray[0] = ROW1;
  3971.         RowArray[1] = ROW2;
  3972.         RowArray[2] = ROW3;
  3973.         RowArray[3] = ROW4;
  3974.         RowArray[4] = ROW5;
  3975.         RowArray[5] = ROW6;
  3976.         RowArray[6] = ROW7;
  3977.         RowArray[7] = ROW8;
  3978.     if (!(sC = OpenScreen((struct NewScreen *)&NewScreenStructure)))
  3979.          {
  3980.           if (RTG)
  3981.            {
  3982.           myTagList[2].ti_Tag = 0; // kill autoscroll and try again
  3983.             myTagList[2].ti_Data = 0;
  3984.           if (!(sC = OpenScreen((struct NewScreen *)&NewScreenStructure)))
  3985.              {
  3986.               //FreeTheBitMap();
  3987.               CloseFont(myTextFont);
  3988.               DisplayError("256 color screen in this mode not avail");
  3989.               return(0);
  3990.              }
  3991.            }
  3992.           else // not rtg
  3993.            {
  3994.             FreeTheBitMap();
  3995.             CloseFont(myTextFont);
  3996.             DisplayError("FATAL:Screen mode not avail");
  3997.             return(0);
  3998.            }
  3999.          }
  4000.         vP = &sC->ViewPort;
  4001.         if (DEPTH >= 6)
  4002.          {
  4003.           if (!FasterDisplay)
  4004.          LoadRGB32(&(sC->ViewPort),BigColorPalette);
  4005.           else
  4006.          LoadRGB32(&(sC->ViewPort),Big64Palette);
  4007.          }
  4008.         else
  4009.      LoadRGB4(&(sC->ViewPort),myPalette,16);
  4010.         if (gfxversion > 38)
  4011.          {
  4012.           NewWindowStructure1.Flags |= WFLG_NEWLOOKMENUS;
  4013.          }
  4014.     NewWindowStructure1.Screen = sC;
  4015.     pNewWindowStructure1.Screen = sC;
  4016.     NewWindowStructure2.Screen = sC;
  4017.     NewWindowStructure5.Screen = sC;
  4018.     NewWindowStructure6.Screen = sC;
  4019.     wG = OpenWindow(&NewWindowStructure1);    /* open the window */
  4020.     if ( wG == NULL )
  4021.      {
  4022.       CloseScreen(sC);
  4023.           CloseFont(myTextFont);
  4024.           FreeTheBitMap();
  4025.           return(0);
  4026.      }
  4027.         globalsignalset = WINDOWSIGNAL;
  4028.     rpG = wG->RPort;    /* get a rastport pointer for the window */
  4029.     SetFont(rpG,myTextFont);
  4030.         Delay(25L); /* crashes from wb if I do not do this! */
  4031.         SetDrMd(rpG,JAM1);
  4032.         if (!InitmyGels())
  4033.          {
  4034.       CloseScreen(sC);
  4035.           CloseFont(myTextFont);
  4036. //          FreeTheBitMap();
  4037.           return(0);
  4038.          }
  4039.         else
  4040.          {
  4041.           if (!LoadFullBitMap())
  4042.            {
  4043.             CloseWindow(wG);
  4044.             CloseScreen(sC);
  4045.            return(0);
  4046.            }
  4047. // finish GEL init and add the bob
  4048.           if (SYSTEM_BOBS)
  4049.            AddBob(TheBob,rpG);
  4050.       WaitTOF();
  4051.        MakeScreen(sC);
  4052.       RethinkDisplay();
  4053.        if (SYSTEM_BOBS)
  4054.           {
  4055.            SortGList(rpG);
  4056.            DrawGList(rpG,vP);
  4057.            MakeVPort(GfxBase->ActiView,vP);
  4058.            MrgCop(GfxBase->ActiView);
  4059.            WaitTOF();
  4060.            SortGList(rpG);
  4061.            DrawGList(rpG,vP);
  4062.            MakeVPort(GfxBase->ActiView,vP);
  4063.            MrgCop(GfxBase->ActiView);
  4064.           WaitTOF();
  4065.           SortGList(rpG);
  4066.            DrawGList(rpG,vP);
  4067.         }
  4068.       MakeVPort(GfxBase->ActiView,vP);
  4069.       MrgCop(GfxBase->ActiView);
  4070.        WaitTOF();
  4071.           MakeScreen(sC);
  4072.        RethinkDisplay();
  4073.        WaitTOF();
  4074.           AmigaStarted = 1;
  4075.           if (gfxversion > 38)
  4076.         bpen = GetBPen(rpG);
  4077.       return(1);
  4078.          }
  4079. }
  4080.  
  4081.  
  4082.  
  4083. void AmigaShutDown()
  4084. {
  4085.  struct IntuiMessage __aligned *message;
  4086.  
  4087.         ClearPointer(wG);
  4088.     CloseGels();
  4089.         while(message = (struct IntuiMessage *)GetMsg(wG->UserPort))
  4090.          ReplyMsg((struct Message *)message);
  4091.         CloseWindow(wG);
  4092.         CloseScreen(sC);
  4093.         FreeTheBitMap();
  4094.         CloseFont(myTextFont);
  4095. /*        system("delete >nil: CLP58.#?");*/
  4096. }
  4097.  
  4098. void ShowMessage(str)
  4099. char *str;
  4100. {
  4101.  char tstr[16];
  4102.  int done = 0;
  4103.  int i=0;
  4104.  int j,k,lim;
  4105.  int ycoord;
  4106.  
  4107.  if (str[strlen(str)-1] == '\n')
  4108.   {
  4109.    str[strlen(str)-1] = 0;
  4110.   }
  4111.  ycoord = SYSTEMBOX+6;
  4112. /* scroll down 3 lines (30 pixels) */
  4113.  BltBitMap(myBitMap,510,SYSTEMBOX,textBitMap,0L,0L,621-510+1,SYSBOXLEN,0xc0L,0xffL,0L);
  4114.  BltBitMap(textBitMap,0,0,myBitMap,510,SYSTEMBOX+30,621-510+1,SYSBOXLEN-30,0xc0L,0xffL,0L);
  4115.  mySetABPenDrMd(rpG,BACKGNDTEXTCOLOR,bpen,JAM1);
  4116.  RectFill(rpG,510,SYSTEMBOX-1,621,SYSTEMBOX+29);
  4117.  mySetABPenDrMd(rpG,BLACK,bpen,JAM1);
  4118.  do {
  4119.  j = i;
  4120.  if (strlen(str) <= 14)
  4121.   {
  4122.    done = 1;
  4123.    strcpy(tstr,str);
  4124.   }
  4125.  else
  4126.   {
  4127.    lim = j + 14;
  4128.    if (lim >= strlen(str))
  4129.     {
  4130.      done = 1;
  4131.      lim = strlen(str);
  4132.     }
  4133.    for(k=0;i<lim;i++,k++)
  4134.     tstr[k] = str[i];
  4135.    tstr[k] = 0;
  4136.   }
  4137.  Move(rpG,510,ycoord); /* was 509,ycord */
  4138.  ycoord += 10;
  4139.  Text(rpG,tstr,strlen(tstr));
  4140.  } while (!done);
  4141. }
  4142.  
  4143.  
  4144.  
  4145. void DisplayComputerMove(str)
  4146. char *str;
  4147. {
  4148.  char tstr[16];
  4149.  int done = 0;
  4150.  int i=0;
  4151.  int j,k,lim;
  4152.  int ycoord;
  4153.  
  4154.  if (str[strlen(str)-1] == '\n')
  4155.   {
  4156.    str[strlen(str)-1] = 0;
  4157.   }
  4158.  mySetABPenDrMd(rpG,BACKGNDTEXTCOLOR,bpen,JAM1);
  4159.  RectFill(rpG,520,COMPUTERBOX,621,COMPUTERBOX+30);
  4160.  ycoord = COMPUTERBOX+6;
  4161.  do {
  4162.  j = i;
  4163.  if (strlen(str) <= 12)
  4164.   {
  4165.    done = 1;
  4166.    strcpy(tstr,str);
  4167.   }
  4168.  else
  4169.   {
  4170.    lim = j + 12;
  4171.    if (lim >= strlen(str))
  4172.     {
  4173.      done = 1;
  4174.      lim = strlen(str);
  4175.     }
  4176.    for(k=0;i<lim;i++,k++)
  4177.     tstr[k] = str[i];
  4178.    tstr[k] = 0;
  4179.   }
  4180.  mySetABPenDrMd(rpG,BLACK,bpen,JAM1);
  4181.  Move(rpG,520,ycoord);
  4182.  ycoord += 10;
  4183.  Text(rpG,tstr,strlen(tstr));
  4184.  } while (!done);
  4185. }
  4186.  
  4187. void DoLegalMove(str)
  4188. char *str;
  4189. {
  4190.  long mpiece;
  4191.  char piece;
  4192.  int r,c,l;
  4193.  int ecol,erow,scol,srow,side,tmp1,tmp2,incrx,incry,i;
  4194.  
  4195.    if (SYSTEM_BOBS)
  4196.     {
  4197.      SortGList(rpG);
  4198.      DrawGList(rpG,vP);
  4199.     }
  4200.    MakeVPort(GfxBase->ActiView,vP);
  4201.    MrgCop(GfxBase->ActiView);
  4202.    if (SYSTEM_BOBS)
  4203.     {
  4204.      RemIBob(TheBob,rpG,vP);
  4205.      SortGList(rpG);
  4206.      DrawGList(rpG,vP);
  4207.     }
  4208.    MakeVPort(GfxBase->ActiView,vP);
  4209.    MrgCop(GfxBase->ActiView);
  4210.    r = str[3] - '1';
  4211.    c = str[2] - 'a';
  4212.    tmp1 = r & 1;
  4213.    tmp2 = c & 1;
  4214.    if (((!tmp1) && (!tmp2)) || ((tmp1)&&(tmp2)))
  4215.     {
  4216.      BltBitMap(BlackBitMap,0,0,myBitMap,ColArray[c],
  4217.             RowArray[r],SQUAREWIDTH,SQUAREHEIGHT,
  4218.             0xc0L,0xffL,0L);
  4219.     }
  4220.    else
  4221.     {
  4222.      BltBitMap(WhiteBitMap,0,0,myBitMap,ColArray[c],
  4223.             RowArray[r],SQUAREWIDTH,SQUAREHEIGHT,
  4224.             0xc0L,0xffL,0L);
  4225.     }
  4226.    MakeVPort(GfxBase->ActiView,vP);
  4227.    MrgCop(GfxBase->ActiView);
  4228.    RethinkDisplay();
  4229.    WaitTOF();
  4230.    l = ((flag.reverse) ? locn (7 - r, 7 - c) : locn (r, c));
  4231.    if ((color[l] == neutral))
  4232.     {
  4233.      ExitChess();
  4234.      return;
  4235.     }
  4236.    else if (color[l] == white)
  4237.     piece = qxx[board[l]]; /* white are lower case pieces */
  4238.    else
  4239.     piece = pxx[board[l]]; /* black are upper case pieces */
  4240.    if ((DestRow == 7)||(!DestRow))
  4241.     { /* possible promotion */
  4242.       mpiece = piece;
  4243.       LoadBobImage(mpiece);
  4244.     }
  4245.    ClipBlitTrans (
  4246.         &(BobTransImage->ti_RP),    /* Source RastPort */
  4247.              0, 0,        /* Source LeftEdge, TopEdge */
  4248.              rpG,        /* Destination RastPort */
  4249.              ColArray[DestCol],RowArray[DestRow],/* Destination LeftEdge, TopEdge */
  4250.              BobTransImage->ti_IM->Width,    /* Width of Image */
  4251.              BobTransImage->ti_IM->Height,/* Height of Image */
  4252.              BobTransImage->ti_sRP);    /* Shadow RastPort */
  4253.    BobVSprite->X = WIDTH-1-BOBWIDTH;
  4254.    BobVSprite->Y = HEIGHT-1-BOBHEIGHT;
  4255.    LoadBobImage(BLANKDATA);
  4256.    if (SYSTEM_BOBS)
  4257.     {
  4258.      AddBob(TheBob,rpG);
  4259.      SortGList(rpG);
  4260.      DrawGList(rpG,vP);
  4261.     }
  4262.    MakeVPort(GfxBase->ActiView,vP);
  4263.    MrgCop(GfxBase->ActiView);
  4264.    if (piece >= 'a')
  4265.     {
  4266.      mpiece = 'r';
  4267.      srow = 0;
  4268.      erow = 0;
  4269.      side = white;
  4270.      if (str[2] == 'g') /* king side white */
  4271.       {
  4272.        scol = 7;
  4273.        ecol = 5;
  4274.       }
  4275.      else
  4276.       {
  4277.        ecol = 3;
  4278.        scol = 0;
  4279.       }
  4280.     }
  4281.    else
  4282.     {
  4283.      mpiece = 'R';
  4284.      srow = 7;
  4285.      erow = 7;
  4286.      side = black;
  4287.      if (str[2] == 'g') /* king side black */
  4288.       {
  4289.        scol = 7;
  4290.        ecol = 5;
  4291.       }
  4292.      else
  4293.       {
  4294.        ecol = 3;
  4295.        scol = 0;
  4296.       }
  4297.     }
  4298.    if (Castled[side])
  4299.     {
  4300.      Castled[side] = 0;
  4301.      tmp1 = srow & 1;
  4302.      tmp2 = scol & 1;
  4303.      if (((!tmp1) && (!tmp2)) || ((tmp1)&&(tmp2)))
  4304.       {
  4305.        BltBitMap(BlackBitMap,0,0,myBitMap,ColArray[scol],
  4306.             RowArray[srow],SQUAREWIDTH,SQUAREHEIGHT,
  4307.             0xc0L,0xffL,0L);
  4308.       }
  4309.      else
  4310.       {
  4311.        BltBitMap(WhiteBitMap,0,0,myBitMap,ColArray[scol],
  4312.             RowArray[srow],SQUAREWIDTH,SQUAREHEIGHT,
  4313.             0xc0L,0xffL,0L);
  4314.       }
  4315.      BobVSprite->X = ColArray[scol];
  4316.      BobVSprite->Y = RowArray[srow];
  4317.      if (SYSTEM_BOBS)
  4318.       {
  4319.        SortGList(rpG);
  4320.        DrawGList(rpG,vP);
  4321.       }
  4322.      MakeVPort(GfxBase->ActiView,vP);
  4323.      MrgCop(GfxBase->ActiView);
  4324.      LoadBobImage(mpiece);
  4325.      if (SYSTEM_BOBS)
  4326.       {
  4327.        SortGList(rpG);
  4328.        DrawGList(rpG,vP);
  4329.       }
  4330.      MakeVPort(GfxBase->ActiView,vP);
  4331.      MrgCop(GfxBase->ActiView);
  4332.      incry = (RowArray[erow] - RowArray[srow])/8;
  4333.      incrx = (ColArray[ecol] - ColArray[scol])/8;
  4334.      for(i=0;i<8;i++)
  4335.       {
  4336.        BobVSprite->X += incrx;
  4337.        BobVSprite->Y += incry;
  4338.        if (SYSTEM_BOBS)
  4339.         {
  4340.          SortGList(rpG);
  4341.          DrawGList(rpG,vP);
  4342.         }
  4343.        MakeVPort(GfxBase->ActiView,vP);
  4344.        MrgCop(GfxBase->ActiView);
  4345.       }
  4346.      if (SYSTEM_BOBS)
  4347.       {
  4348.        RemIBob(TheBob,rpG,vP);
  4349.        SortGList(rpG);
  4350.        DrawGList(rpG,vP);
  4351.       }
  4352.      MakeVPort(GfxBase->ActiView,vP);
  4353.      MrgCop(GfxBase->ActiView);
  4354.      ClipBlitTrans (
  4355.             &(BobTransImage->ti_RP),    /* Source RastPort */
  4356.                  0, 0,        /* Source LeftEdge, TopEdge */
  4357.                  rpG,        /* Destination RastPort */
  4358.                  ColArray[ecol],RowArray[erow],/* Destination LeftEdge, TopEdge */
  4359.                  BobTransImage->ti_IM->Width,    /* Width of Image */
  4360.                  BobTransImage->ti_IM->Height,/* Height of Image */
  4361.                  BobTransImage->ti_sRP);    /* Shadow RastPort */
  4362.      LoadBobImage(BLANKDATA);
  4363.      if (SYSTEM_BOBS)
  4364.       {
  4365.        AddBob(TheBob,rpG);
  4366.       }
  4367.      MakeVPort(GfxBase->ActiView,vP);
  4368.      MrgCop(GfxBase->ActiView);
  4369.     }
  4370.    else /* check EnPassant */
  4371.     {
  4372.      side ^= 1;
  4373.      if (myEnPassant[side])
  4374.       {
  4375.        myEnPassant[side] = 0;
  4376.        scol = str[2] - 'a';
  4377.        if (str[3] == '3') /* white is removed from bd at 4*/
  4378.         {
  4379.          srow = 3;
  4380.         }
  4381.        else /* black is removed at pos 5 */
  4382.         {
  4383.          srow = 4;
  4384.         }
  4385.        tmp1 = srow & 1;
  4386.        tmp2 = scol & 1;
  4387.        if (((!tmp1) && (!tmp2)) || ((tmp1)&&(tmp2)))
  4388.         {
  4389.          BltBitMap(BlackBitMap,0,0,myBitMap,ColArray[scol],
  4390.             RowArray[srow],SQUAREWIDTH,SQUAREHEIGHT,
  4391.             0xc0L,0xffL,0L);
  4392.         }
  4393.        else
  4394.         {
  4395.          BltBitMap(WhiteBitMap,0,0,myBitMap,ColArray[scol],
  4396.             RowArray[srow],SQUAREWIDTH,SQUAREHEIGHT,
  4397.             0xc0L,0xffL,0L);
  4398.         }
  4399.       }
  4400.     }
  4401. }
  4402.  
  4403. void DrawAmigaBoard()
  4404. {
  4405.  int r,c,l,tmp1,tmp2;
  4406.  int piece;
  4407.  
  4408.  LoadBobImage(BLANKDATA);
  4409.  BobVSprite->X = WIDTH-1-BOBWIDTH;
  4410.  BobVSprite->Y = HEIGHT-1-BOBHEIGHT;
  4411.  if (SYSTEM_BOBS)
  4412.   {
  4413.    SortGList(rpG);
  4414.    DrawGList(rpG,vP);
  4415.    RemIBob(TheBob,rpG,vP);
  4416.    SortGList(rpG);
  4417.    DrawGList(rpG,vP);
  4418.   }
  4419.  for(r=0;r<8;r++)
  4420.   for(c=0;c<8;c++)
  4421.    {
  4422.        tmp1 = r & 1;
  4423.        tmp2 = c & 1;
  4424.        if (((!tmp1) && (!tmp2)) || ((tmp1)&&(tmp2)))
  4425.         {
  4426.          BltBitMap(BlackBitMap,0,0,myBitMap,ColArray[c],
  4427.             RowArray[r],SQUAREWIDTH,SQUAREHEIGHT,
  4428.             0xc0L,0xffL,0L);
  4429.         }
  4430.        else
  4431.         {
  4432.          BltBitMap(WhiteBitMap,0,0,myBitMap,ColArray[c],
  4433.             RowArray[r],SQUAREWIDTH,SQUAREHEIGHT,
  4434.             0xc0L,0xffL,0L);
  4435.         }    
  4436.     l = ((flag.reverse) ? locn (7 - r, 7 - c) : locn (r, c));
  4437.     if (color[l] == white)
  4438.      piece = qxx[board[l]]; /* white are lower case pieces */
  4439.     else
  4440.      piece = pxx[board[l]]; /* black are upper case pieces */
  4441.     if (color[l] != neutral)
  4442.      {
  4443.       BobVSprite->X = ColArray[c];
  4444.       BobVSprite->Y = RowArray[r];
  4445.       LoadBobImage(piece);
  4446.       ClipBlitTrans (
  4447.         &(BobTransImage->ti_RP),    /* Source RastPort */
  4448.              0, 0,        /* Source LeftEdge, TopEdge */
  4449.              rpG,        /* Destination RastPort */
  4450.              ColArray[c],RowArray[r],/* Destination LeftEdge, TopEdge */
  4451.              BobTransImage->ti_IM->Width,    /* Width of Image */
  4452.              BobTransImage->ti_IM->Height,/* Height of Image */
  4453.              BobTransImage->ti_sRP);    /* Shadow RastPort */
  4454.      }
  4455.    }
  4456.  BobVSprite->X = WIDTH-1-BOBWIDTH;
  4457.  BobVSprite->Y = HEIGHT-1-BOBHEIGHT;
  4458.  LoadBobImage(BLANKDATA);
  4459.  if (SYSTEM_BOBS)
  4460.   AddBob(TheBob,rpG);
  4461. }
  4462.  
  4463.  
  4464. void GetOperatorEntry(str)
  4465. char *str;
  4466. {
  4467.  char __aligned PromoteChar;
  4468.  char mvnstr[16];
  4469.  ULONG signals;
  4470.  char __aligned tempstr[40];
  4471.  struct IntuiMessage __aligned *message;
  4472.  long done=0;
  4473.  long done2;
  4474.  int ilen=0;
  4475.  int r,c,l,piece;
  4476.  long __aligned class,code;
  4477.  int MouseX,MouseY;
  4478.  long tmp1,tmp2;
  4479.  
  4480.  
  4481.  
  4482.  ClearPointer(wG);
  4483.  if (CheckIllegal)
  4484.   {
  4485.    CheckIllegal = 0;
  4486.    if (IllegalMove)
  4487.     { /* put guy back! */
  4488.       IllegalMove = 0;
  4489.       if (SYSTEM_BOBS)
  4490.        {
  4491.         RemIBob(TheBob,rpG,vP);
  4492.         SortGList(rpG); 
  4493.         DrawGList(rpG,vP);
  4494.        }
  4495.       MakeVPort(GfxBase->ActiView,vP);
  4496.       MrgCop(GfxBase->ActiView);
  4497.       ClipBlitTrans (
  4498.         &(BobTransImage->ti_RP),    /* Source RastPort */
  4499.              0, 0,        /* Source LeftEdge, TopEdge */
  4500.              rpG,        /* Destination RastPort */
  4501.              ColArray[OrigCol],RowArray[OrigRow],/* Destination LeftEdge, TopEdge */
  4502.              BobTransImage->ti_IM->Width,    /* Width of Image */
  4503.              BobTransImage->ti_IM->Height,/* Height of Image */
  4504.              BobTransImage->ti_sRP);    /* Shadow RastPort */
  4505.       BobVSprite->X = WIDTH-1-BOBWIDTH;
  4506.       BobVSprite->Y = HEIGHT-1-BOBHEIGHT;
  4507.       LoadBobImage(BLANKDATA);
  4508.       if (SYSTEM_BOBS)
  4509.        AddBob(TheBob,rpG);
  4510.       MakeVPort(GfxBase->ActiView,vP);
  4511.       MrgCop(GfxBase->ActiView);
  4512.     }
  4513.   }
  4514.  while (message = (struct IntuiMessage *)GetMsg(wG->UserPort))
  4515.    {
  4516.      ReplyMsg((struct Message *)message);
  4517.    }
  4518.  mySetABPenDrMd(rpG,BACKGNDTEXTCOLOR,bpen,JAM1);
  4519.  RectFill(rpG,520,USERBOX,621,USERBOX+30);
  4520.  Move(rpG,520,USERBOX+6);
  4521.  if (computer != black)
  4522.   sprintf(mvnstr,"%d: ",(GameCnt+1)>>1);
  4523.  else
  4524.   sprintf(mvnstr,"%d: ",(GameCnt+2)>>1);
  4525.  mySetABPenDrMd(rpG,BLACK,bpen,JAM1);
  4526.  Text(rpG,mvnstr,strlen(mvnstr));
  4527.  tempstr[0] = 0;
  4528.  PromoteChar = 0;
  4529.  OnMenu(wG,SHOWMENUNUM); 
  4530.  OnMenu(wG,SUPERMENUNUM); 
  4531.  OnMenu(wG,THINKMENUNUM); 
  4532.  OnMenu(wG,BOOKMENUNUM); 
  4533.  do {
  4534.  if (!globalmessage_valid)
  4535.   signals = Wait(globalsignalset);
  4536.  if ((signals & WINDOWSIGNAL)||(globalmessage_valid))
  4537.  {
  4538.   message = (struct IntuiMessage *)1;
  4539.   while (message)
  4540.   {
  4541.   if (!globalmessage_valid)
  4542.    message = (struct IntuiMessage *)GetMsg(wG->UserPort);
  4543.   if ((message)||(globalmessage_valid))
  4544.    {
  4545.         if (!globalmessage_valid)
  4546.          {
  4547.       class = message->Class;
  4548.       code = message->Code;
  4549.           MouseX = message->MouseX;
  4550.           MouseY = message->MouseY;
  4551.       ReplyMsg((struct Message *)message);
  4552.          }
  4553.         else
  4554.          {
  4555.       class = globalmessage.Class;
  4556.       code = globalmessage.Code;
  4557.           MouseX = globalmessage.MouseX;
  4558.           MouseY = globalmessage.MouseY;
  4559.           globalmessage_valid = 0L;
  4560.          }
  4561.     if ( class == MENUPICK )    /* MenuItems */
  4562.          {
  4563.           if (code != MENUNULL)
  4564.            {
  4565.          HandleEvent((APTR)ItemAddress(&MenuList1,code));
  4566.             if (flag.quit) 
  4567.              done = 1;
  4568.             else
  4569.              {
  4570.               if (teston)
  4571.                {
  4572.                 done = 1;
  4573.                 teston = 0;
  4574.                 strcpy(tempstr,"test");
  4575.                }
  4576.               else if (doswap)
  4577.                {
  4578.                 done = 1;
  4579.                 doswap = 0;
  4580.                 strcpy(tempstr,"switch");
  4581.                }
  4582.               else if (doauto)
  4583.                {
  4584.                 done = 1;
  4585.                 doauto = 0;
  4586.                 strcpy(tempstr,"both");
  4587.                }
  4588.               else if (doundo)
  4589.                {
  4590.                 done = 1;
  4591.                 doundo = 0;
  4592.                 strcpy(tempstr,"help");
  4593.                }
  4594.              }
  4595.            }
  4596.          }
  4597.     else if (class == RAWKEY)
  4598.      {
  4599.           if (code < 80)
  4600.            {
  4601.           code = cookedchar[code];
  4602.           if ((code == 13)||(code == 10))
  4603.        {
  4604.             done = 1;
  4605.        }
  4606.           else if ((code == 7)&&(ilen)) /* backspace */
  4607.            {
  4608.             tempstr[strlen(tempstr)-1] = '\0';
  4609.             mySetABPenDrMd(rpG,BACKGNDTEXTCOLOR,bpen,JAM1);
  4610.             RectFill(rpG,520,USERBOX,621,USERBOX+30);
  4611.             mySetABPenDrMd(rpG,BLACK,bpen,JAM1);
  4612.             Move(rpG,520,USERBOX+6);
  4613.             if (computer != black)
  4614.              sprintf(mvnstr,"%d: ",(GameCnt+1)>>1);
  4615.             else
  4616.             sprintf(mvnstr,"%d: ",(GameCnt+2)>>1);
  4617.             Text(rpG,mvnstr,strlen(mvnstr));
  4618.             Text(rpG,tempstr,strlen(tempstr));
  4619.             ilen--;
  4620.            }
  4621.           else if ((isalnum(code)||(code == '-')||(code == '/')) && (strlen(tempstr) < 12))
  4622.            {
  4623.             tempstr[ilen] = tolower(code);
  4624.             mySetABPenDrMd(rpG,BLACK,bpen,JAM1);
  4625.             Move(rpG,520,USERBOX+6);
  4626.             ilen++;
  4627.             tempstr[ilen] = 0;
  4628.             if (computer != black)
  4629.              sprintf(mvnstr,"%d: ",(GameCnt+1)>>1);
  4630.             else
  4631.             sprintf(mvnstr,"%d: ",(GameCnt+2)>>1);
  4632.             Text(rpG,mvnstr,strlen(mvnstr));
  4633.             Text(rpG,tempstr,strlen(tempstr));
  4634.            }
  4635.           } /* code < 80 */
  4636.      }
  4637.         else if ((class == MOUSEBUTTONS)&&(!(flag.quit || flag.mate || flag.force)))
  4638.          {
  4639.           if ((code == SELECTDOWN) && 
  4640.               ((MouseY <= (ROW1+SQUAREHEIGHT)) && (MouseY >= ROW8) && (MouseX <= (COLH+BOBWIDTH)) &&
  4641.                (MouseX >= COLA)))
  4642.            {
  4643.             if (MouseX < COLB)
  4644.              OrigCol = 0;
  4645.             else if (MouseX < COLC)
  4646.              OrigCol = 1;
  4647.             else if (MouseX < COLD)
  4648.              OrigCol = 2;
  4649.             else if (MouseX < COLE)
  4650.              OrigCol = 3;
  4651.             else if (MouseX < COLF)
  4652.              OrigCol = 4;
  4653.             else if (MouseX < COLG)
  4654.              OrigCol = 5;
  4655.             else if (MouseX < COLH)
  4656.              OrigCol = 6;
  4657.             else 
  4658.              OrigCol = 7;
  4659.             if (MouseY < ROW7)
  4660.              OrigRow = 7;
  4661.             else if (MouseY < ROW6)
  4662.              OrigRow = 6;
  4663.             else if (MouseY < ROW5)
  4664.              OrigRow = 5;
  4665.             else if (MouseY < ROW4)
  4666.              OrigRow = 4;
  4667.             else if (MouseY < ROW3)
  4668.              OrigRow = 3;
  4669.             else if (MouseY < ROW2)
  4670.              OrigRow = 2;
  4671.             else if (MouseY < ROW1)
  4672.              OrigRow = 1;
  4673.             else 
  4674.              OrigRow = 0;
  4675.             tmp1 = OrigRow & 1L;
  4676.             tmp2 = OrigCol & 1L;
  4677.             done2 = 0;
  4678.             r = OrigRow;
  4679.             c = OrigCol;
  4680.             l = ((flag.reverse) ? locn (7 - r, 7 - c) : locn (r, c));
  4681.             if ((color[l] == neutral)||(opponent != color[l]))
  4682.              {
  4683.               done2 = 1;
  4684.              }
  4685.             else if (color[l] == white)
  4686.              piece = qxx[board[l]]; /* white are lower case pieces */
  4687.             else
  4688.              piece = pxx[board[l]]; /* black are upper case pieces */
  4689.             if (!done2)
  4690.              {
  4691.               if (((!tmp1) && (!tmp2)) || ((tmp1)&&(tmp2)))
  4692.                {
  4693.                 BltBitMap(BlackBitMap,0,0,myBitMap,ColArray[OrigCol],
  4694.             RowArray[OrigRow],SQUAREWIDTH,SQUAREHEIGHT,
  4695.             0xc0L,0xffL,0L);
  4696.                }
  4697.               else
  4698.                {
  4699.                 BltBitMap(WhiteBitMap,0,0,myBitMap,ColArray[OrigCol],
  4700.             RowArray[OrigRow],SQUAREWIDTH,SQUAREHEIGHT,
  4701.             0xc0L,0xffL,0L);
  4702.                }
  4703.               BobVSprite->X = WIDTH-1-BOBWIDTH;
  4704.               BobVSprite->Y = HEIGHT-1-BOBHEIGHT;
  4705.               LoadBobImage(BLANKDATA);
  4706.               if (SYSTEM_BOBS)
  4707.                {
  4708.                 SortGList(rpG);
  4709.                 DrawGList(rpG,vP);
  4710.                }
  4711.               MakeVPort(GfxBase->ActiView,vP);
  4712.               MrgCop(GfxBase->ActiView);
  4713.               CheckIllegal = 1;
  4714.               IllegalMove = 0;
  4715.  /* NOW POSITION BOB AND LOAD IN ITS CORRECT PIECE IMAGE */
  4716.           LoadBobImage(piece);
  4717.               BobVSprite->X = MouseX - 24;
  4718.               BobVSprite->Y = MouseY - 16;
  4719.               if (SYSTEM_BOBS)
  4720.                {
  4721.                 SortGList(rpG);
  4722.                 DrawGList(rpG,vP);
  4723.                }
  4724.               MakeVPort(GfxBase->ActiView,vP);
  4725.               MrgCop(GfxBase->ActiView);
  4726.              }
  4727.             ModifyIDCMP(wG,NewWindowStructure1.IDCMPFlags | INTUITICKS);
  4728.             do {
  4729.             signals = Wait(globalsignalset);
  4730.             if (signals & WINDOWSIGNAL)
  4731.              {
  4732.               while ( (message = (struct IntuiMessage *)
  4733.           GetMsg(wG->UserPort) ))
  4734.               {
  4735.           class = message->Class;
  4736.           code = message->Code;
  4737.               MouseX = message->MouseX;
  4738.               MouseY = message->MouseY;
  4739.           ReplyMsg((struct Message *)message);
  4740.               if (!done2)
  4741.                {
  4742.               if ((class == MOUSEBUTTONS)&&(code == SELECTUP))
  4743.                { /* now try and make the move */
  4744.                 done2 = 1;
  4745.         if ((MouseX > (COLH+SQUAREWIDTH)) || (MouseX < COLA) ||
  4746.                     (MouseY < ROW8) || (MouseY > (ROW1+BOBHEIGHT)))
  4747.                  { /* Put the Piece Back */
  4748.                    BobVSprite->X = WIDTH-1-BOBWIDTH;
  4749.                    BobVSprite->Y = HEIGHT-1-BOBHEIGHT;
  4750.                    tmp1 = lastpiece;
  4751.            LoadBobImage(BLANKDATA);
  4752.                    if (SYSTEM_BOBS)
  4753.                     {
  4754.                      SortGList(rpG);
  4755.                      DrawGList(rpG,vP);
  4756.                      RemIBob(TheBob,rpG,vP);
  4757.                      SortGList(rpG);
  4758.                      DrawGList(rpG,vP);
  4759.                     }
  4760.                    MakeVPort(GfxBase->ActiView,vP);
  4761.                    MrgCop(GfxBase->ActiView);
  4762.            LoadBobImage(tmp1);
  4763.                    ClipBlitTrans (
  4764.               &(BobTransImage->ti_RP),    /* Source RastPort */
  4765.               0, 0,        /* Source LeftEdge, TopEdge */
  4766.               rpG,        /* Destination RastPort */
  4767.               ColArray[OrigCol],RowArray[OrigRow],/* Destination LeftEdge, TopEdge */
  4768.               BobTransImage->ti_IM->Width,    /* Width of Image */
  4769.               BobTransImage->ti_IM->Height,/* Height of Image */
  4770.               BobTransImage->ti_sRP);    /* Shadow RastPort */
  4771.                    BobVSprite->X = WIDTH-1-BOBWIDTH;
  4772.                    BobVSprite->Y = HEIGHT-1-BOBHEIGHT;
  4773.                    LoadBobImage(BLANKDATA);
  4774.                    if (SYSTEM_BOBS)
  4775.                     {
  4776.                      AddBob(TheBob,rpG);
  4777.                      SortGList(rpG);
  4778.                      DrawGList(rpG,vP);
  4779.                     }
  4780.                    MakeVPort(GfxBase->ActiView,vP);
  4781.                    MrgCop(GfxBase->ActiView);
  4782.                  }
  4783.                 else
  4784.                  {
  4785.                   done = 1; /* try the move */
  4786.                   if (MouseX < COLB)
  4787.                    DestCol = 0;
  4788.                   else if (MouseX < COLC)
  4789.                    DestCol = 1;
  4790.                   else if (MouseX < COLD)
  4791.                    DestCol = 2;
  4792.                   else if (MouseX < COLE)
  4793.                    DestCol = 3;
  4794.                   else if (MouseX < COLF)
  4795.                    DestCol = 4;
  4796.                   else if (MouseX < COLG)
  4797.                    DestCol = 5;
  4798.                   else if (MouseX < COLH)
  4799.                    DestCol = 6;
  4800.                   else 
  4801.                    DestCol = 7;
  4802.                   if (MouseY < ROW7)
  4803.                    DestRow = 7;
  4804.                   else if (MouseY < ROW6)
  4805.                    DestRow = 6;
  4806.                   else if (MouseY < ROW5)
  4807.                    DestRow = 5;
  4808.                   else if (MouseY < ROW4)
  4809.                    DestRow = 4;
  4810.                   else if (MouseY < ROW3)
  4811.                    DestRow = 3;
  4812.                   else if (MouseY < ROW2)
  4813.                    DestRow = 2;
  4814.                   else if (MouseY < ROW1)
  4815.                    DestRow = 1;
  4816.                   else 
  4817.                    DestRow = 0;
  4818.                   if ((DestRow == OrigRow) && (DestCol == OrigCol))
  4819.                    {
  4820.                     done = 0;
  4821.             tmp1 = lastpiece;
  4822.             LoadBobImage(BLANKDATA);
  4823.                     BobVSprite->X = WIDTH-1-BOBWIDTH;
  4824.                     BobVSprite->Y = HEIGHT-1-BOBHEIGHT;
  4825.                     if (SYSTEM_BOBS)
  4826.                      {
  4827.                       SortGList(rpG);
  4828.                       DrawGList(rpG,vP);
  4829.                       RemIBob(TheBob,rpG,vP);
  4830.                       SortGList(rpG);
  4831.                       DrawGList(rpG,vP);
  4832.                      }
  4833.                     MakeVPort(GfxBase->ActiView,vP);
  4834.                     MrgCop(GfxBase->ActiView);
  4835.             LoadBobImage(tmp1);
  4836.                     ClipBlitTrans (
  4837.             &(BobTransImage->ti_RP),    /* Source RastPort */
  4838.                  0, 0,        /* Source LeftEdge, TopEdge */
  4839.                  rpG,        /* Destination RastPort */
  4840.                  ColArray[OrigCol],RowArray[OrigRow],/* Destination LeftEdge, TopEdge */
  4841.                  BobTransImage->ti_IM->Width,    /* Width of Image */
  4842.                  BobTransImage->ti_IM->Height,/* Height of Image */
  4843.                  BobTransImage->ti_sRP);    /* Shadow RastPort */
  4844.                     BobVSprite->X = WIDTH-1-BOBWIDTH;
  4845.                     BobVSprite->Y = HEIGHT-1-BOBHEIGHT;
  4846.                     LoadBobImage(BLANKDATA);
  4847.                     if (SYSTEM_BOBS)
  4848.                      {
  4849.                       AddBob(TheBob,rpG);
  4850.                       SortGList(rpG);
  4851.                       DrawGList(rpG,vP);
  4852.                      }
  4853.                     MakeVPort(GfxBase->ActiView,vP);
  4854.                     MrgCop(GfxBase->ActiView);
  4855.                    }
  4856.                   else
  4857.                   {
  4858.                    MouseDropped = 1;
  4859.             if (((piece == 'p')&&(DestRow == 7))||/* possible prom wht */
  4860.                        ((piece == 'P')&&(!DestRow))) /* possible blk promotion */
  4861.                      {
  4862.                       PromoteChar = DisplayPromoteRequestor();
  4863.                      }
  4864.                    tempstr[4] = 0;
  4865.                    tempstr[0] = OrigCol + 'a';
  4866.                    tempstr[1] = OrigRow + '1';
  4867.                    tempstr[2] = DestCol + 'a';
  4868.                    tempstr[3] = DestRow + '1';
  4869.                    mySetABPenDrMd(rpG,BLACK,bpen,JAM1);
  4870.                    Move(rpG,520,USERBOX+6);
  4871.                    if (computer != black)
  4872.                     sprintf(mvnstr,"%d: ",(GameCnt+1)>>1);
  4873.                    else
  4874.                     sprintf(mvnstr,"%d: ",(GameCnt+2)>>1);
  4875.                    Text(rpG,mvnstr,strlen(mvnstr));
  4876.                    Text(rpG,tempstr,strlen(tempstr));
  4877.                   }
  4878.                  }
  4879.                }
  4880.               else if (class == INTUITICKS)
  4881.                {
  4882.                 BobVSprite->X = MouseX - 24;
  4883.                 BobVSprite->Y = MouseY - 16;
  4884.                 if (SYSTEM_BOBS)
  4885.                  {
  4886.                   SortGList(rpG);
  4887.                   DrawGList(rpG,vP);
  4888.                  }
  4889.                 MakeVPort(GfxBase->ActiView,vP);
  4890.                 MrgCop(GfxBase->ActiView);
  4891.                }
  4892.                } /* ! done2 */
  4893.               }
  4894.              } /* signals & WINDOWSIGNAL */
  4895.             } while (!done2);
  4896.             ModifyIDCMP(wG,NewWindowStructure1.IDCMPFlags);
  4897.             while ( (message = (struct IntuiMessage *)
  4898.          GetMsg(wG->UserPort) ))
  4899.              {
  4900.           ReplyMsg((struct Message *)message);
  4901.              }
  4902.            }
  4903.          }
  4904.    }
  4905.   } /* while message */
  4906.   } /* signals & windowsignal */
  4907.   } while (!done);
  4908. OffMenu(wG,SHOWMENUNUM); 
  4909. OffMenu(wG,BOOKMENUNUM); 
  4910. OffMenu(wG,SUPERMENUNUM); 
  4911. OffMenu(wG,THINKMENUNUM); 
  4912. if (tempstr[2] == '-')
  4913.  {
  4914.   for(ilen=2;ilen<strlen(tempstr);ilen++)
  4915.    tempstr[ilen] = tempstr[ilen+1];
  4916.  }
  4917. if (tempstr[4] == '/')
  4918.  {
  4919.   for(ilen=4;ilen<strlen(tempstr);ilen++)
  4920.    tempstr[ilen] = tempstr[ilen+1];
  4921.  }
  4922. if ((!PromoteChar)&&((strlen(tempstr) == 2) || (strlen(tempstr) == 4)))
  4923.  {
  4924.   r = tempstr[1] - '1';
  4925.   if ((strlen(tempstr) == 2)&&(opponent == white))
  4926.    {
  4927.     r--;
  4928.    }
  4929.   else if ((strlen(tempstr) == 2)&&(opponent == black))
  4930.    {
  4931.     r++;
  4932.    }
  4933.   c = tempstr[0] - 'a';
  4934.   l = ((flag.reverse) ? locn (7 - r, 7 - c) : locn (r, c));
  4935.   if ((color[l] == neutral)||(opponent != color[l]))
  4936.    {
  4937.     done2 = 1;
  4938.    }
  4939.   else if (color[l] == white)
  4940.    piece = qxx[board[l]]; /* white are lower case pieces */
  4941.   else
  4942.    piece = pxx[board[l]]; /* black are upper case pieces */
  4943.   if (strlen(tempstr) == 4)
  4944.    {
  4945.      r = tempstr[3] - '1';
  4946.    }
  4947.   else
  4948.    {
  4949.     if (opponent == white)
  4950.      {
  4951.       r++;
  4952.      }
  4953.      else
  4954.      {
  4955.       r--;
  4956.      }
  4957.    }
  4958.   if (((piece == 'p')&&(r == 7))||/* possible prom wht */
  4959.       ((piece == 'P')&&(!r))) /* possible blk promotion */
  4960.     {
  4961.      PromoteChar = DisplayPromoteRequestor();
  4962.      if (strlen(tempstr) == 2)
  4963.       {
  4964.        if (!r)
  4965.         {
  4966.          tempstr[4] = 0;
  4967.          tempstr[3] = tempstr[1];
  4968.          tempstr[2] = tempstr[0];
  4969.          tempstr[1]++;
  4970.         }
  4971.        else
  4972.         {
  4973.          tempstr[4] = 0;
  4974.          tempstr[3] = tempstr[1];
  4975.          tempstr[2] = tempstr[0];
  4976.          tempstr[1]--;  
  4977.         }
  4978.       }
  4979.     }
  4980.  }
  4981. if (PromoteChar)
  4982.  {
  4983.   ilen = strlen(tempstr);
  4984.   tempstr[ilen] = PromoteChar;
  4985.   tempstr[ilen+1] = 0;
  4986.  }
  4987. strcpy(str,tempstr);
  4988. if (!(stricmp(str,"new")))
  4989.  {
  4990.     BobVSprite->X = WIDTH-1-BOBWIDTH;
  4991.     BobVSprite->Y = HEIGHT-1-BOBHEIGHT;
  4992.     LoadBobImage(BLANKDATA);
  4993.     if (SYSTEM_BOBS)
  4994.      {
  4995.       SortGList(rpG);
  4996.       DrawGList(rpG,vP);
  4997.      }
  4998.     MakeVPort(GfxBase->ActiView,vP);
  4999.     MrgCop(GfxBase->ActiView);
  5000.     WaitTOF();
  5001.     RethinkDisplay();
  5002.  }
  5003. }
  5004.  
  5005. void AnimateAmigaMove(str,piece)
  5006. char *str;
  5007. char piece; /* black are upper case pieces, white lower case */
  5008. {
  5009.  int side;
  5010.  int tmp1,tmp2;
  5011.  int srow,scol,erow,ecol,incrx,incry,i;
  5012.  long mpiece;
  5013.  
  5014.  
  5015.  mpiece = piece;
  5016.  if (!MouseDropped)
  5017.   {
  5018.    BobVSprite->X = WIDTH-1-BOBWIDTH;
  5019.    BobVSprite->Y = HEIGHT-1-BOBHEIGHT;
  5020.    LoadBobImage(BLANKDATA);
  5021.    if (SYSTEM_BOBS)
  5022.     {
  5023.      SortGList(rpG);
  5024.      DrawGList(rpG,vP);
  5025.     }
  5026.    MakeVPort(GfxBase->ActiView,vP);
  5027.    MrgCop(GfxBase->ActiView);
  5028.    scol = str[0] - 'a';
  5029.    srow = str[1] - '1';
  5030.    ecol = str[2] - 'a';
  5031.    erow = str[3] - '1';
  5032.    tmp1 = srow & 1;
  5033.    tmp2 = scol & 1;
  5034.    if (((!tmp1) && (!tmp2)) || ((tmp1)&&(tmp2)))
  5035.     {
  5036.      BltBitMap(BlackBitMap,0,0,myBitMap,ColArray[scol],
  5037.         RowArray[srow],SQUAREWIDTH,SQUAREHEIGHT,
  5038.         0xc0L,0xffL,0L);
  5039.     }
  5040.    else
  5041.     {
  5042.      BltBitMap(WhiteBitMap,0,0,myBitMap,ColArray[scol],
  5043.         RowArray[srow],SQUAREWIDTH,SQUAREHEIGHT,
  5044.         0xc0L,0xffL,0L);
  5045.     }
  5046.    tmp1 = erow & 1;
  5047.    tmp2 = ecol & 1;
  5048.    if (((!tmp1) && (!tmp2)) || ((tmp1)&&(tmp2)))
  5049.     {
  5050.      BltBitMap(BlackBitMap,0,0,myBitMap,ColArray[ecol],
  5051.         RowArray[erow],SQUAREWIDTH,SQUAREHEIGHT,
  5052.         0xc0L,0xffL,0L);
  5053.     }
  5054.    else
  5055.     {
  5056.      BltBitMap(WhiteBitMap,0,0,myBitMap,ColArray[ecol],
  5057.         RowArray[erow],SQUAREWIDTH,SQUAREHEIGHT,
  5058.         0xc0L,0xffL,0L);
  5059.     }
  5060.    BobVSprite->X = ColArray[scol];
  5061.    BobVSprite->Y = RowArray[srow];
  5062.    LoadBobImage(mpiece);
  5063.    if (SYSTEM_BOBS)
  5064.     {
  5065.      SortGList(rpG);
  5066.      DrawGList(rpG,vP);
  5067.     }
  5068.    MakeVPort(GfxBase->ActiView,vP);
  5069.    MrgCop(GfxBase->ActiView);
  5070.    incry = (RowArray[erow] - RowArray[srow])/8;
  5071.    incrx = (ColArray[ecol] - ColArray[scol])/8;
  5072.    for(i=0;i<8;i++)
  5073.     {
  5074.      BobVSprite->X += incrx;
  5075.      BobVSprite->Y += incry;
  5076.      if (SYSTEM_BOBS)
  5077.       {
  5078.        SortGList(rpG);
  5079.        DrawGList(rpG,vP);
  5080.       }
  5081.      MakeVPort(GfxBase->ActiView,vP);
  5082.      MrgCop(GfxBase->ActiView);
  5083.     }
  5084.    if (SYSTEM_BOBS)
  5085.     {
  5086.      RemIBob(TheBob,rpG,vP);
  5087.      SortGList(rpG);
  5088.      DrawGList(rpG,vP);
  5089.     }
  5090.    MakeVPort(GfxBase->ActiView,vP);
  5091.    MrgCop(GfxBase->ActiView);
  5092.    ClipBlitTrans (
  5093.         &(BobTransImage->ti_RP),    /* Source RastPort */
  5094.              0, 0,        /* Source LeftEdge, TopEdge */
  5095.              rpG,        /* Destination RastPort */
  5096.              ColArray[ecol],RowArray[erow],/* Destination LeftEdge, TopEdge */
  5097.              BobTransImage->ti_IM->Width,    /* Width of Image */
  5098.              BobTransImage->ti_IM->Height,/* Height of Image */
  5099.              BobTransImage->ti_sRP);    /* Shadow RastPort */
  5100.    BobVSprite->X = WIDTH-1-BOBWIDTH;
  5101.    BobVSprite->Y = HEIGHT-1-BOBHEIGHT;
  5102.    LoadBobImage(BLANKDATA);
  5103.    if (SYSTEM_BOBS)
  5104.     {
  5105.      AddBob(TheBob,rpG);
  5106.     }
  5107.    MakeVPort(GfxBase->ActiView,vP);
  5108.    MrgCop(GfxBase->ActiView);
  5109.    if (piece >= 'a')
  5110.     {
  5111.      mpiece = 'r';
  5112.      srow = 0;
  5113.      erow = 0;
  5114.      side = white;
  5115.      if (str[2] == 'g') /* king side white */
  5116.       {
  5117.        scol = 7;
  5118.        ecol = 5;
  5119.       }
  5120.      else
  5121.       {
  5122.        ecol = 3;
  5123.        scol = 0;
  5124.       }
  5125.     }
  5126.    else
  5127.     {
  5128.      mpiece = 'R';
  5129.      srow = 7;
  5130.      erow = 7;
  5131.      side = black;
  5132.      if (str[2] == 'g') /* king side black */
  5133.       {
  5134.        scol = 7;
  5135.        ecol = 5;
  5136.       }
  5137.      else
  5138.       {
  5139.        ecol = 3;
  5140.        scol = 0;
  5141.       }
  5142.     }
  5143.    if (Castled[side])
  5144.     {
  5145.      Castled[side] = 0;
  5146.      tmp1 = srow & 1;
  5147.      tmp2 = scol & 1;
  5148.      if (((!tmp1) && (!tmp2)) || ((tmp1)&&(tmp2)))
  5149.       {
  5150.        BltBitMap(BlackBitMap,0,0,myBitMap,ColArray[scol],
  5151.             RowArray[srow],SQUAREWIDTH,SQUAREHEIGHT,
  5152.             0xc0L,0xffL,0L);
  5153.       }
  5154.      else
  5155.       {
  5156.        BltBitMap(WhiteBitMap,0,0,myBitMap,ColArray[scol],
  5157.             RowArray[srow],SQUAREWIDTH,SQUAREHEIGHT,
  5158.             0xc0L,0xffL,0L);
  5159.       }
  5160.      BobVSprite->X = ColArray[scol];
  5161.      BobVSprite->Y = RowArray[srow];
  5162.      if (SYSTEM_BOBS)
  5163.       {
  5164.        SortGList(rpG);
  5165.        DrawGList(rpG,vP);
  5166.       }
  5167.      MakeVPort(GfxBase->ActiView,vP);
  5168.      MrgCop(GfxBase->ActiView);
  5169.      LoadBobImage(mpiece);
  5170.      if (SYSTEM_BOBS)
  5171.       {
  5172.        SortGList(rpG);
  5173.        DrawGList(rpG,vP);
  5174.       }
  5175.      MakeVPort(GfxBase->ActiView,vP);
  5176.      MrgCop(GfxBase->ActiView);
  5177.      incry = (RowArray[erow] - RowArray[srow])/8;
  5178.      incrx = (ColArray[ecol] - ColArray[scol])/8;
  5179.      for(i=0;i<8;i++)
  5180.       {
  5181.        BobVSprite->X += incrx;
  5182.        BobVSprite->Y += incry;
  5183.        if (SYSTEM_BOBS)
  5184.         {
  5185.          SortGList(rpG);
  5186.          DrawGList(rpG,vP);
  5187.         }
  5188.        MakeVPort(GfxBase->ActiView,vP);
  5189.        MrgCop(GfxBase->ActiView);
  5190.       }
  5191.      if (SYSTEM_BOBS)
  5192.       {
  5193.        RemIBob(TheBob,rpG,vP);
  5194.        SortGList(rpG);
  5195.        DrawGList(rpG,vP);
  5196.       }
  5197.      MakeVPort(GfxBase->ActiView,vP);
  5198.      MrgCop(GfxBase->ActiView);
  5199.      ClipBlitTrans (
  5200.             &(BobTransImage->ti_RP),    /* Source RastPort */
  5201.                  0, 0,        /* Source LeftEdge, TopEdge */
  5202.                  rpG,        /* Destination RastPort */
  5203.                  ColArray[ecol],RowArray[erow],/* Destination LeftEdge, TopEdge */
  5204.                  BobTransImage->ti_IM->Width,    /* Width of Image */
  5205.                  BobTransImage->ti_IM->Height,/* Height of Image */
  5206.                  BobTransImage->ti_sRP);    /* Shadow RastPort */
  5207.      LoadBobImage(BLANKDATA);
  5208.      if (SYSTEM_BOBS)
  5209.       {
  5210.        AddBob(TheBob,rpG);
  5211.       }
  5212.      MakeVPort(GfxBase->ActiView,vP);
  5213.      MrgCop(GfxBase->ActiView);
  5214.     }
  5215.    else /* check EnPassant */
  5216.     {
  5217.      side ^= 1;
  5218.      if (myEnPassant[side])
  5219.       {
  5220.        myEnPassant[side] = 0;
  5221.        scol = str[2] - 'a';
  5222.        if (str[3] == '3') /* white is removed from bd at 4*/
  5223.         {
  5224.          srow = 3;
  5225.         }
  5226.        else /* black is removed at pos 5 */
  5227.         {
  5228.          srow = 4;
  5229.         }
  5230.        tmp1 = srow & 1;
  5231.        tmp2 = scol & 1;
  5232.        if (((!tmp1) && (!tmp2)) || ((tmp1)&&(tmp2)))
  5233.         {
  5234.          BltBitMap(BlackBitMap,0,0,myBitMap,ColArray[scol],
  5235.             RowArray[srow],SQUAREWIDTH,SQUAREHEIGHT,
  5236.             0xc0L,0xffL,0L);
  5237.         }
  5238.        else
  5239.         {
  5240.          BltBitMap(WhiteBitMap,0,0,myBitMap,ColArray[scol],
  5241.             RowArray[srow],SQUAREWIDTH,SQUAREHEIGHT,
  5242.             0xc0L,0xffL,0L);
  5243.         }
  5244.       }
  5245.     }
  5246.   }
  5247. }
  5248.  
  5249. #endif /* AMIGA */
  5250.  
  5251.  
  5252. void GetTimeString(str)
  5253. char *str;
  5254. {
  5255. #ifdef AMIGA
  5256. #endif
  5257. }
  5258.  
  5259.  
  5260.  
  5261. char __aligned *ColorStr[2];
  5262. char __far __aligned *CP[CPSIZE];
  5263. /*
  5264.  * In a networked enviroment gnuchess might be compiled on different hosts
  5265.  * with different random number generators, that is not acceptable if they
  5266.  * are going to share the same transposition table.
  5267.  */
  5268.  
  5269. unsigned int
  5270. urand (void)
  5271. {
  5272.   next *= 1103515245;
  5273.   next += 12345;
  5274.   return ((unsigned int) (next >> 16) & 0xFFFF);
  5275. }
  5276.  
  5277.  
  5278. unsigned long __aligned hashkey, hashbd;
  5279. #ifdef LONGINTS2
  5280. struct hashval __far hashcode[2][7][64];
  5281. #else
  5282. struct hashval __aligned hashcode[2][7][64];
  5283. #endif
  5284.  
  5285. #ifdef CACHE
  5286. #ifdef ttblsz
  5287. struct hashentry huge __aligned *ttable[2];
  5288. unsigned int __aligned ttblsize;
  5289. #endif
  5290.  
  5291. #else
  5292.  
  5293. #ifdef ttblsz
  5294. struct hashentry __aligned __far ttable[2][vttblsz + MAXrehash];
  5295. unsigned int __aligned ttblsize;
  5296. #endif
  5297.  
  5298. #endif
  5299.  
  5300. char __far __aligned savefile[128] = "";
  5301. char __far __aligned listfile[128] = "";
  5302. #ifdef HISTORY
  5303. unsigned char __far __aligned history[32768];
  5304. #endif
  5305. INTSIZE __aligned rpthash[2][256];
  5306. struct leaf __far __aligned Tree[TREE];
  5307. struct leaf  __aligned *root;
  5308. INTSIZE __aligned TrPnt[MAXDEPTH];
  5309. INTSIZE __aligned PieceList[2][64], PawnCnt[2][8];
  5310. INTSIZE __aligned castld[2], Mvboard[64];
  5311. INTSIZE __aligned svalue[64];
  5312. struct flags __aligned flag;
  5313. INTSIZE __aligned opponent, computer, WAwindow, WBwindow, BAwindow, BBwindow, dither, INCscore;
  5314. long __aligned ResponseTime, ExtraTime, MaxResponseTime, et, et0, time0, ft;
  5315. long __aligned GenCnt, NodeCnt, ETnodes, EvalNodes, HashCnt, HashAdd, FHashCnt, FHashAdd, HashCol,
  5316.  THashCol, filesz;
  5317. long __aligned replus, reminus;
  5318. INTSIZE __aligned HashDepth = HASHDEPTH, HashMoveLimit = HASHMOVELIMIT;
  5319. INTSIZE __aligned player, xwndw, rehash;
  5320. struct GameRec __aligned GameList[MAXMOVES + MAXDEPTH];
  5321. INTSIZE __aligned Sdepth, GameCnt, Game50, MaxSearchDepth;
  5322. INTSIZE __aligned epsquare, contempt;
  5323. int __aligned Book;
  5324. struct TimeControlRec __aligned TimeControl;
  5325. INTSIZE __aligned TCflag, TCmoves, TCminutes, TCseconds, OperatorTime;
  5326. INTSIZE __aligned XCmoves[3], XCminutes[3], XCseconds[3], XC, XCmore;
  5327. const INTSIZE __aligned otherside[3] =
  5328. {black, white, neutral};
  5329. unsigned INTSIZE __aligned hint;
  5330. INTSIZE int __aligned TOflag;        /* force search re-init if we backup search */
  5331.  
  5332. INTSIZE __aligned mtl[2], pmtl[2], hung[2];
  5333. INTSIZE __aligned Pindex[64];
  5334. INTSIZE __aligned PieceCnt[2];
  5335. INTSIZE __aligned FROMsquare, TOsquare;
  5336. INTSIZE __aligned HasKnight[2], HasBishop[2], HasRook[2], HasQueen[2];
  5337. INTSIZE __aligned ChkFlag[MAXDEPTH], CptrFlag[MAXDEPTH], PawnThreat[MAXDEPTH];
  5338. INTSIZE __aligned Pscore[MAXDEPTH], Tscore[MAXDEPTH];
  5339. const INTSIZE __aligned qrook[3] =
  5340. {0, 56, 0};
  5341. const INTSIZE __aligned krook[3] =
  5342. {7, 63, 0};
  5343. const INTSIZE __aligned kingP[3] =
  5344. {4, 60, 0};
  5345. const INTSIZE __aligned rank7[3] =
  5346. {6, 1, 0};
  5347. const INTSIZE __aligned sweep[8] =
  5348. {false, false, false, true, true, true, false, false};
  5349. unsigned INTSIZE __aligned killr0[MAXDEPTH], killr1[MAXDEPTH];
  5350. unsigned INTSIZE __aligned killr2[MAXDEPTH], killr3[MAXDEPTH];
  5351. unsigned INTSIZE __aligned PV, SwagHt, Swag0, Swag1, Swag2, Swag3, Swag4;
  5352.  
  5353. #ifdef USE_SIDEBIT
  5354. unsigned INTSIZE __aligned sidebit;
  5355. #endif
  5356.  
  5357. #ifdef KILLT
  5358. INTSIZE __far __aligned killt[0x4000];
  5359. #endif
  5360. const INTSIZE __aligned value[7] =
  5361. {0, valueP, valueN, valueB, valueR, valueQ, valueK};
  5362. const INTSIZE __aligned control[7] =
  5363. {0, ctlP, ctlN, ctlB, ctlR, ctlQ, ctlK};
  5364. INTSIZE __aligned stage, stage2, Developed[2];
  5365. FILE __aligned *hashfile;
  5366. unsigned int __aligned starttime;
  5367. INTSIZE int __aligned ahead = true, hash = true;
  5368.  
  5369. #if defined CHESSTOOL || defined XBOARD
  5370. void
  5371. TerminateChess (int sig)
  5372. {
  5373.   ExitChess();
  5374. }
  5375. #endif
  5376.  
  5377. int __aligned timeopp[MINGAMEIN], timecomp[MINGAMEIN];
  5378. int __aligned compptr, oppptr;
  5379.  
  5380. inline void
  5381. TimeCalc ()
  5382. {
  5383. /* adjust number of moves remaining in gamein games */
  5384.   int increment = 0;
  5385.   int topsum = 0;
  5386.   int tcompsum = 0;
  5387.   int me,him;
  5388.   int i;
  5389. /* dont do anything til you have enough numbers */
  5390.   if (GameCnt < (MINGAMEIN * 2)) return;
  5391. /* calculate average time in sec for last MINGAMEIN moves */
  5392.   for (i = 0; i < MINGAMEIN; i++)
  5393.     {
  5394.       tcompsum += timecomp[i];
  5395.       topsum += timeopp[i];
  5396.     }
  5397.   topsum /= (100 * MINGAMEIN);
  5398.   tcompsum /= (100 * MINGAMEIN);
  5399. /* if I have less time than opponent add another move */
  5400.     me = TimeControl.clock[computer]/100; 
  5401.     him = TimeControl.clock[opponent]/100;
  5402.     if(me < him) increment += 2;
  5403. /* if I am losing more time with each move add another */
  5404.   /*if ( !((me - him) > 60) && tcompsum > topsum) increment++;*/
  5405.   if ( tcompsum > topsum) increment +=2;
  5406. /* but dont let moves go below MINMOVES */
  5407.   else if (TimeControl.moves[computer] < MINMOVES && !increment) increment++;
  5408. /* if I am doing really well use more time per move */
  5409.   else if (me > him && tcompsum < topsum) increment = -1;
  5410.   TimeControl.moves[computer] += increment;
  5411. }
  5412.  
  5413.  
  5414. /* hmm.... shouldn`t main be moved to the interface routines */
  5415. int
  5416. main (int aargc, char **aargv)
  5417. {
  5418.   char cstring[40];
  5419.   char *xwin = 0;
  5420.   char *Lang = NULL;
  5421.  
  5422. #ifdef AMIGA
  5423.  int tmpargcnt;
  5424.  struct WBStartup *startmsg;
  5425.  struct ExecBase **execbaseptr=(struct ExecBase **)4L;
  5426.  UWORD cpuid;
  5427.  struct ExecBase *execbase;
  5428.  BPTR fp;
  5429.  APTR tempxx;
  5430.  struct WBArg *mywbptr;
  5431.  struct DiskObject *dob;
  5432.  
  5433.  execbase = *execbaseptr;
  5434.  cpuid = execbase->AttnFlags;
  5435.  
  5436.  if (!(cpuid & AFF_68020))
  5437.   {
  5438.    exit(0);
  5439.   }
  5440.  gfxversion = GfxBase->LibNode.lib_Version;
  5441.  if (gfxversion < 37)
  5442.   exit(-1);
  5443.  if (!aargc)
  5444.   {
  5445.    startmsg = (struct WBStartup *)aargv;
  5446.    mywbptr = startmsg->sm_ArgList; 
  5447.    if (dob = GetDiskObject (mywbptr->wa_Name))
  5448.     {
  5449.      xwin = FindToolType(dob->do_ToolTypes,"PRI");
  5450.      if (xwin)
  5451.       {
  5452.        procpri = xwin[0] - '0';
  5453.        if (procpri < 0)
  5454.         procpri = 0;
  5455.        if (procpri > 4)
  5456.         procpri = 4;
  5457.       }
  5458.      xwin = FindToolType(dob->do_ToolTypes,"COLORS");
  5459.      if (xwin)
  5460.       {
  5461.        if ((xwin[0] == '1')&&(xwin[1] == '6'))
  5462.         gfxversion = 37;
  5463.        else if ((xwin[0] == '6')&&(xwin[1] == '4'))
  5464.         FasterDisplay = 1;
  5465.       }
  5466.      xwin = FindToolType(dob->do_ToolTypes,"MONITOR");
  5467.      if (xwin)
  5468.       {
  5469.        if ((xwin[0] == '1')&&(xwin[1] == '5'))
  5470.         v15Khz = 1;
  5471.       }
  5472.      xwin = FindToolType(dob->do_ToolTypes,"FASTAGA");
  5473.      if (xwin)
  5474.       {
  5475.        if ((xwin[0] == '1')||(xwin[0] == 'O')||(xwin[0] == 'o'))
  5476.         FasterDisplay = 1;
  5477.       }
  5478.      xwin = FindToolType(dob->do_ToolTypes,"SUPER72");
  5479.      if (xwin)
  5480.       {
  5481.        if ((xwin[0] == '1')||(xwin[0] == 'O')||(xwin[0] == 'o'))
  5482.         Super72 = 1;
  5483.       }
  5484.      xwin = FindToolType(dob->do_ToolTypes,"RTG");
  5485.      if (xwin)
  5486.       {
  5487.        if ((xwin[0] == '1')||(xwin[0] == 'O')||(xwin[0] == 'o'))
  5488.         RTG = 1;
  5489.       }
  5490. //     xwin = FindToolType(dob->do_ToolTypes,"PICASSO");
  5491. //     if (xwin)
  5492. //      {
  5493. //       if ((xwin[0] == '1')||(xwin[0] == 'O')||(xwin[0] == 'o'))
  5494. //        Picasso = 1;
  5495. //      }
  5496.      xwin = FindToolType(dob->do_ToolTypes,"NO_BOBS");
  5497.      if (xwin)
  5498.       {
  5499.        if ((xwin[0] == '1')||(xwin[0] == 'O')||(xwin[0] == 'o'))
  5500.         SYSTEM_BOBS = 0;
  5501.       }
  5502.      FreeDiskObject (dob);
  5503.     }
  5504.    xwin = 0L;
  5505.   }
  5506.  else if (aargc > 1)
  5507.   {
  5508.    for(tmpargcnt=1;tmpargcnt<aargc;tmpargcnt++)
  5509.     {
  5510.      if (!(strcmp(aargv[tmpargcnt],"16")))
  5511.       {
  5512.        gfxversion = 37;
  5513.       }
  5514.      else if (!(stricmp(aargv[tmpargcnt],"Super72")))
  5515.       {
  5516.        Super72 = 1;
  5517.       }
  5518.      else if (!(stricmp(aargv[tmpargcnt],"RTG")))
  5519.       {
  5520.        RTG = 1;
  5521.       }
  5522.      else if (!(stricmp(aargv[tmpargcnt],"NOBOBS")))
  5523.       {
  5524.        SYSTEM_BOBS = 0;
  5525.       }
  5526.      else if (!(stricmp(aargv[tmpargcnt],"15KHZ")))
  5527.       {
  5528.        v15Khz = 1;
  5529.       }
  5530. //     else if (!(stricmp(aargv[tmpargcnt],"PICASSO")))
  5531. //      {
  5532. //       Picasso = 1;
  5533. //      }
  5534.      else if ((!(stricmp(aargv[tmpargcnt],"FASTAGA")))||((!(strcmp(aargv[tmpargcnt],"64")))))
  5535.       {
  5536.        FasterDisplay = 1;
  5537.       }
  5538.      else if (strcmp(aargv[tmpargcnt],"256"))
  5539.       {
  5540.        procpri=atoi(aargv[tmpargcnt]);
  5541.        if (procpri < 0)
  5542.          procpri = 0;
  5543.        if (procpri > 4)
  5544.         procpri = 4;
  5545.       }
  5546.     }
  5547.   }
  5548.  if (gfxversion < 39)
  5549.   RTG = Super72 = 0;
  5550.  if (RTG)
  5551.   {
  5552.    FasterDisplay = 0;
  5553.    v15Khz = 0;
  5554.   }
  5555. // if (!RTG)
  5556. //  Picasso = 0;
  5557.  Delay(3L);
  5558.  myproc = (struct Process *)FindTask(0L);
  5559.  tempxx = myproc->pr_WindowPtr;
  5560.  Delay(3L);
  5561.  myproc->pr_WindowPtr = (APTR)-1L;
  5562.  if (!(fp = Open("uchess:uchess.lang",MODE_OLDFILE)))
  5563.   {
  5564.    system("Assign >nil: uchess: \"\"");
  5565.   }
  5566.  else
  5567.   Close(fp);
  5568.  myproc->pr_WindowPtr = tempxx;
  5569. #endif
  5570.  
  5571.   
  5572.   gsrand (starttime = ((unsigned int) time ((long *) 0)));    /* init urand */
  5573. #ifdef ttblsz
  5574.   ttblsize = ttblsz;
  5575.   rehash = -1;
  5576. #endif /* ttblsz */
  5577.   flag.easy = 0;
  5578. #ifndef AMIGA
  5579.   if (argc > 2)
  5580.     {
  5581.       if (argv[1][0] == '-' && argv[1][1] == 'L')
  5582.     {
  5583.       Lang = argv[2];
  5584.       argv += 2;
  5585.       argc -= 2;
  5586.     }
  5587.     }
  5588. #endif
  5589.   InitConst (Lang);
  5590.   ColorStr[0] = CP[118];
  5591.   ColorStr[1] = CP[119];
  5592.  
  5593. #ifndef AMIGA
  5594.   while (argc > 1 && ((argv[1][0] == '-') || (argv[1][0] == '+')))
  5595.     {
  5596.       switch (argv[1][1])
  5597.     {
  5598.     case 'a':
  5599.       ahead = ((argv[1][0] == '-') ? false : true);
  5600.       break;
  5601.     case 'h':
  5602.       hash = ((argv[1][0] == '-') ? false : true);
  5603.       break;
  5604.     case 's':
  5605.       argc--;
  5606.       argv++;
  5607.       if (argc > 1)
  5608.         strcpy (savefile, argv[1]);
  5609.       break;
  5610.     case 'l':
  5611.       argc--;
  5612.       argv++;
  5613.       if (argc > 1)
  5614.         strcpy (listfile, argv[1]);
  5615.       break;
  5616.  
  5617. #if ttblsz
  5618.     case 'r':
  5619.       if (argc > 2)
  5620.         rehash = atoi (argv[2]);
  5621.       argc--;
  5622.       argv++;
  5623.       if (rehash > MAXrehash)
  5624.         rehash = MAXrehash;
  5625.       break;
  5626.     case 'T':
  5627.       if (argc > 2)
  5628.         ttblsize = atoi (argv[2]);
  5629.       argc--;
  5630.       argv++;
  5631.       if (ttblsize > 0 && ttblsize < 24)
  5632.         ttblsize = (1 << ttblsize);
  5633.       else
  5634.         ttblsize = ttblsz;
  5635.       break;
  5636. #ifdef HASHFILE
  5637.     case 't':        /* create or test persistent transposition
  5638.                  * table */
  5639.       hashfile = fopen (HASHFILE, RWA_ACC);
  5640.       if (hashfile)
  5641.         {
  5642.           fseek (hashfile, 0L, SEEK_END);
  5643.           filesz = (ftell (hashfile) / sizeof (struct fileentry)) - 1;
  5644.         }
  5645.       if (hashfile != NULL)
  5646.         {
  5647.           long i, j;
  5648.           int nr[MAXDEPTH];
  5649.           struct fileentry n;
  5650.  
  5651.           /*ShowMessage (CP[49]);*/
  5652.           for (i = 0; i < MAXDEPTH; i++)
  5653.         nr[i] = 0;
  5654.           fseek (hashfile, 0L, SEEK_END);
  5655.           i = ftell (hashfile) / sizeof (struct fileentry);
  5656.           fseek (hashfile, 0L, SEEK_SET);
  5657.           for (j = 0; j < i + 1; j++)
  5658.         {
  5659.           fread (&n, sizeof (struct fileentry), 1, hashfile);
  5660.           if (n.depth)
  5661.             {
  5662.               nr[n.depth]++;
  5663.               nr[0]++;
  5664.             }
  5665.         }
  5666.           sprintf (astr,CP[109],
  5667.               nr[0], i);
  5668.               /*ShowMessage(astr);*/
  5669.           for (j = 1; j < MAXDEPTH; j++)
  5670.                /*
  5671.         printf ("%d ", nr[j]);
  5672.           printf ("\n")*/;
  5673.         }
  5674.       return 0;
  5675.     case 'c':        /* create or test persistent transposition
  5676.                  * table */
  5677.       if (argc > 2)
  5678.         filesz = atoi (argv[2]);
  5679.       if (filesz > 0 && filesz < 24)
  5680.         filesz = (1 << filesz) - 1 + MAXrehash;
  5681.       else
  5682.         filesz = Deffilesz + MAXrehash;
  5683.       if ((hashfile = fopen (HASHFILE, RWA_ACC)) == NULL)
  5684.         hashfile = fopen (HASHFILE, WA_ACC);
  5685.       if (hashfile != NULL)
  5686.         {
  5687.           long j;
  5688.           struct fileentry n;
  5689.  
  5690.           /*printf (CP[66]);*/
  5691.           for (j = 0; j < 32; j++)
  5692.         n.bd[j] = 0;
  5693.           n.f = n.t = 0;
  5694.           n.flags = 0;
  5695.           n.depth = 0;
  5696.           n.sh = n.sl = 0;
  5697.           for (j = 0; j < filesz + 1; j++)
  5698.         fwrite (&n, sizeof (struct fileentry), 1, hashfile);
  5699.           fclose (hashfile);
  5700.         }
  5701.      /* else
  5702.         printf (CP[50], HASHFILE);*/
  5703.       return (0);
  5704. #endif /* HASHFILE */
  5705. #endif /* ttblsz */
  5706.     case 'x':
  5707.       xwin = &argv[1][2];
  5708.       break;
  5709.     case 'v':
  5710. /*      fprintf (stderr, CP[102], version, patchlevel);*/
  5711.       exit (1);
  5712.     default:
  5713.       /*fprintf (stderr, CP[113]);*/
  5714.       exit (1);
  5715.     }
  5716.       argv++;
  5717.       argc--;
  5718.     }
  5719. #endif
  5720.   XC = 0;
  5721.   MaxResponseTime = 0;
  5722. #if defined CHESSTOOL || defined XBOARD
  5723.   signal (SIGTERM, TerminateChess);
  5724.   TCflag = true;
  5725.   TCmoves = 40;
  5726.   TCminutes = 120;
  5727.   TCseconds = 0;
  5728.   TCadd = 0;
  5729.   OperatorTime = 0;
  5730. #else
  5731. /*  TCflag = false;*/
  5732. /*  OperatorTime = 0;*/
  5733.   TCflag = true;
  5734.   TCmoves = 60;
  5735.   TCminutes = 10;
  5736.   TCseconds = 0;
  5737.   OperatorTime = 0;
  5738. #endif
  5739. #ifndef AMIGA
  5740.   if (argc == 2)
  5741.     {
  5742.       char *p;
  5743.  
  5744.       MaxResponseTime = 100L*strtol(argv[1], &p, 10);
  5745.       if (*p == ':')
  5746.     MaxResponseTime = 60L*MaxResponseTime + 
  5747.         100L*strtol(++p, (char **) NULL, 10);
  5748.       TCflag = false;
  5749.       TCmoves = 0;
  5750.       TCminutes = 0;
  5751.       TCseconds = 0;
  5752.     }
  5753.   if (argc >= 3)
  5754.     {
  5755.       char *p;
  5756.       if (argc > 9)
  5757.     {
  5758.      /* printf ("%s\n", CP[220]);*/
  5759.       exit (1);
  5760.     }
  5761.       TCmoves = atoi (argv[1]);
  5762.       TCminutes = strtol (argv[2], &p, 10);
  5763.       if (*p == ':')
  5764.     TCseconds = strtol (p + 1, (char **) NULL, 10);
  5765.       else
  5766.     TCseconds = 0;
  5767.       TCflag = true;
  5768.       argc -= 3;
  5769.       argv += 3;
  5770.       while (argc > 1)
  5771.     {
  5772.       XCmoves[XC] = atoi (argv[0]);
  5773.       XCminutes[XC] = strtol (argv[1], &p, 10);
  5774.       if (*p == ':')
  5775.         XCseconds[XC] = strtol (p + 1, (char **) NULL, 10);
  5776.       else
  5777.         XCseconds[XC] = 0;
  5778.       if (XCmoves[XC] && (XCminutes[XC] || XCseconds[XC]))
  5779.         XC++;
  5780.       else
  5781.         {
  5782.           /*printf (CP[220]);*/
  5783.           exit (1);
  5784.         }
  5785.       argc -= 2;
  5786.       argv += 2;
  5787.     }
  5788.       if (argc)
  5789.     {
  5790.       /*printf ("%s\n", CP[220]);*/
  5791.       exit (1);
  5792.     }
  5793.     }
  5794. #endif /* AMIGA */
  5795. #ifdef AMIGA
  5796.  if (!AmigaStartup())
  5797.   {
  5798.    exit(2);
  5799.   }
  5800. #endif
  5801.   Initialize ();
  5802. #ifndef CACHE
  5803. #ifdef ttblsz
  5804.   Initialize_ttable ();
  5805. #endif /* ttblsz */
  5806. #endif
  5807.   Initialize_dist ();
  5808.   Initialize_moves ();
  5809.   FirstTime = 1;
  5810.   NewGame ();
  5811.   flag.easy = ahead;
  5812.   flag.hash = hash;
  5813.   if (xwin)
  5814.     xwndw = atoi (xwin);
  5815.  
  5816.   hashfile = NULL;
  5817. #if ttblsz
  5818. #ifdef HASHFILE
  5819.   hashfile = fopen (HASHFILE, RWA_ACC);
  5820.   if (hashfile)
  5821.     {
  5822.       fseek (hashfile, 0L, SEEK_END);
  5823.       filesz = ftell (hashfile) / sizeof (struct fileentry) - 1;
  5824.     }
  5825. #if !defined CHESSTOOL && !defined XBOARD
  5826.   else
  5827.     ShowMessage (CP[98]);
  5828. #endif
  5829. #endif /* HASHFILE */
  5830. #endif /* ttblsz */
  5831. #ifdef AMIGA
  5832.  (void)SetTaskPri((struct Task *)myproc,procpri);
  5833.  Delay(3L);
  5834.  SetMenuStrip(wG,&MenuList1);    /* attach any Menu */
  5835.  MenuStripSet = 1;
  5836. #endif
  5837.   while (!(flag.quit))
  5838.     {
  5839.       oppptr = (oppptr + 1) % MINGAMEIN;
  5840.       if (flag.bothsides && !flag.mate)
  5841.        {
  5842.         SetPointer(wG,myPointer,PTRHEIGHT,0x10L,0L,0L);
  5843.     SelectMove (opponent, 1);
  5844.        }
  5845.       else
  5846.         {
  5847.       InputCommand (cstring);
  5848.         }
  5849.  
  5850.       if (opponent == black)
  5851.     if (flag.gamein || TCadd)
  5852.       {
  5853.         TimeCalc ();
  5854.       }
  5855.     else if (TimeControl.moves[opponent] == 0)
  5856.       {
  5857.         if (XC)
  5858.           if (XCmore < XC)
  5859.         {
  5860.           TCmoves = XCmoves[XCmore];
  5861.           TCminutes = XCminutes[XCmore];
  5862.           TCseconds = XCseconds[XCmore];
  5863.           XCmore++;
  5864.         }
  5865.         SetTimeControl2 (opponent);
  5866.       }
  5867.  
  5868.       compptr = (compptr + 1) % MINGAMEIN;
  5869.  
  5870.  
  5871.       if (SupervisorMode)
  5872.        {
  5873.       computer = computer ^ 1;
  5874.       opponent = opponent ^ 1;
  5875.       xwndw = (computer == white) ? WXWNDW : BXWNDW;
  5876.       flag.force = false;
  5877.       Sdepth = 0;
  5878.        }
  5879.       else if (!(flag.quit || flag.mate || flag.force))
  5880.     {
  5881.           SetPointer(wG,myPointer,PTRHEIGHT,0x10L,0L,0L);
  5882.       SelectMove (computer, 1);
  5883.       if (computer == black)
  5884.         if (flag.gamein)
  5885.           {
  5886.         TimeCalc ();
  5887.           }
  5888.         else if (TimeControl.moves[computer] == 0)
  5889.           {
  5890.         if (XC)
  5891.           if (XCmore < XC)
  5892.             {
  5893.               TCmoves = XCmoves[XCmore];
  5894.               TCminutes = XCminutes[XCmore];
  5895.               TCseconds = XCseconds[XCmore];
  5896.               XCmore++;
  5897.             }
  5898.         SetTimeControl2 (computer);
  5899.           }
  5900.     }
  5901.       if ((flag.mate)&&(!Mate)&&(!DrawnGame))
  5902.        ShowMessage("CheckMate");
  5903.       if (Mate)
  5904.        {
  5905.         ShowMessage(MateString);
  5906.        }
  5907.       else if (DrawnGame)
  5908.        {
  5909.         ShowMessage("Draw..");
  5910.        }
  5911.       else if ((!flag.mate)&&(PlayMode == 2)&&(!ResignOffered)&&(!flag.quit))
  5912.        {
  5913.         if (global_tmp_score < -950)
  5914.          {
  5915.           if (DoResign())
  5916.            {
  5917.             flag.mate = true;
  5918.             Mate = 1;
  5919.             ShowMessage("You Win!");
  5920.             ShowMessage("UChess Resigns");
  5921.            }
  5922.          }
  5923.        }
  5924.     }
  5925. #if ttblsz
  5926. #ifdef HASHFILE
  5927.   if (hashfile)
  5928.     fclose (hashfile);
  5929. #endif /* HASHFILE */
  5930. #endif /* ttblsz */
  5931.  
  5932.   ExitChess ();
  5933. }
  5934.